Engineering
Engineering, 16.04.2020 04:03, webbjalia04

Homework: Chapter 23a Using our implementation of ChargeCard. py as the base class, write a RewardsChargeCard class in a file named RewardsChargeCard. py) that simulates a credit card that rewards its users by giving them some percentage of money back. Formal Specifications A RewardsChargechard must use ChargeCard as its base class. Such a card has a reward rate - the percentage of money the user gets back as rewards for each charge transaction. The rewards are accumulated until used. When rewards are used, the accumulated reward amount is deposited into the card and accumulated reward amount is reset to zero. A ChargeCard must support the following calling syntaxes: · Constructor The constructor should accept two required parameters, designating the spending limit on the card and the reward rate (as a float). Additionally, the constructor must accept an optional parameter that designates an initial balance with the balance being 0 by default). For example, the syntax # using default value of balance card = RewardsChargeCard(1000, 0.01) would create a new card, with spending limit of 1000, reward rate of 0.01, and an initial balance of zero. # specifying the value of balance explicitly card = RewardsChargeCard(1000, 0.01, 100) would create a new card, with a spending limit of 1000, reward rate of 0.01, and an initial balance of 100. • charge(amount) The RewardsChargeCard should override the parent class implementation of this method by: • First calling the parent class implementation of charge (amount) o Updating the value of accumulated rewards. Each charge transaction earns (amount * reward rate) toward the accumulated rewards. Rewards will only be added on valid transactions (if the charge is accepted). o Returning True if the amount does not exceed the sum of the current card balance and the card limit, and False otherwise. For example, the following operations would result in the accumulated reward value 10. card=RewardChargeCard(10000, 0.01) card. charge(1000) If the charge is invalid (over the limit) the rewards are not added. For example, the following operations would result in no rewards card = RewardChargeCard (10000, 0.01, 1000) # inital balance is 1000 card. charge (10000) # charge is over the limit+balance, invalid operation, no rewards • getRewards A call to this method returns the value of accumulated rewards. • useRewards() A call to this method applies the currently accumulated rewards to the balance and then sets the rewards total to 0. Applying rewards to the balance is identical to depositing money to the card, and a convenient way to apply accumulated rewards to the balance is by using the parent class deposit(amount) method and then setting the reward total to 0.

answer
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, alyssabailey7545
Give heat transfer applications for the following, (i) gas turbines (propulsion) ) gas turbines (power generation). (iii) steam turbines. (iv) combined heat and power (chp). (v) automotive engines
Answers: 1
image
Engineering, 04.07.2019 19:10, nani3906
Starting wih an energy balance on a rectangular volume element, derive the one- dimensional transient heat conduction equation for a plane wall with constant thermal conductivity and no heat generation.
Answers: 1
image
Engineering, 04.07.2019 19:10, shayshay7874
An electric kettle is made out of stainless steel, weighs two pounds (when empty) and is equipped with a heating element that consumes 2 kw of electricity. assuming that the water and the kettle are at the same uniform temperature at any moment of time, calculate the shortest possible time to bring 2 quarts of water from room temperature to the onset of boiling
Answers: 2
image
Engineering, 04.07.2019 19:20, dndndndnxmnc
The process in which the system pressure remain constant is called a)-isobaric b)-isochoric c)-isolated d)-isothermal
Answers: 3
Do you know the correct answer?
Homework: Chapter 23a Using our implementation of ChargeCard. py as the base class, write a RewardsC...

Questions in other subjects:

Konu
English, 28.05.2020 20:04
Konu
History, 28.05.2020 20:04
Konu
History, 28.05.2020 20:04