Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write code in java. you don't need giftcard.java you can write your own code Part 1 A Basic Object In this section we'll build

Please write code in java.

image text in transcribed

you don't need giftcard.java you can write your own code
Part 1 A Basic Object In this section we'll build a small class together (starting from the above template), useful for managing a gift card balance. This class will keep track of the total balance and will allow for a starting total, deductions, and a balance report. To manage such details, we'll need a class-level (or instance) variable to store the balance, as well as a few methods to implement the actions mentioned above. Download GiftCard.java and look at the main method. Explain to your partner what is happening in each line of the main method of Gift Card. How do card1, card, and card3 differ from each other, after each line of the code? Add a class-level variable to track the balance at the top of the file. Should this variable be a char? A double? Add a constructor that will set the class-level instance variable you defined earlier when you create an instance of GiftCard. Add a void method setBalance(double new Balance) that resets the balance. Make this function fail on negative input Add a void method deduct(double amount) method that subtracts from the balance Make this function fail on a negative balance Add a void method report() that prints out the balance remaining on the gift card

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago