subject
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.

ansver
Answers: 2

Another question on Engineering

question
Engineering, 04.07.2019 12:10
On a average work day more than work place firs are reorted
Answers: 1
question
Engineering, 04.07.2019 18:10
The thermal expansion or contraction of a given metal is a function of the f a)-density b)-initial temperature c)- temperature difference d)- linear coefficient of thermal expansion e)- final temperature f)- original length
Answers: 2
question
Engineering, 04.07.2019 18:10
Which from the following instrument is commonly used to detect the high pitch butzing sound in bearings? [clo4] a)-digital ultrasonic meter b)-infrared camera c)-spectroscopic d)-vibrometer
Answers: 2
question
Engineering, 04.07.2019 19:10
With increases in magnification, which of the following occur? a. the field of view decreases. b. the ambient illumination decreases. c. the larger parts can be measured. d. the eyepiece must be raised.
Answers: 1
You know the right answer?
Homework: Chapter 23a Using our implementation of ChargeCard. py as the base class, write a RewardsC...
Questions
question
Social Studies, 21.09.2019 12:50
question
Mathematics, 21.09.2019 12:50