Question: Complete the GiftCard class shown below. A GiftCard keeps track of the current balance and the maximum balance. A gift card starts with a beginning
Complete the GiftCard class shown below. A GiftCard keeps track of the current balance and the maximum balance. A gift card starts with a beginning balance. A GiftCard can be used to make a purchase, funds can be added to a GiftCard, and the balance can be checked at any time. The balance can never be negative. If the amount added to the card is $100 or more, a bonus of $10 is also added. public class GiftCard { // declare instance variables // precondition: the starting balance is not negative // postcondition: all instance variables are initialized public GiftCard(double startBal) { } // postcondition: amount is subtracted from balance // if there are insufficient funds, the balance is set to zero and a message // is displayed to indicate how much of the transaction is still owed public void spendFunds(double amount) { } // postcondition: amount is added to balance, if the amount is at least 100 dollars, // 10 dollars is added public void addFunds(double amount) { } // postcondition: the current balance is returned public double checkBalance() { } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
