Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code that will mimic a collection of Gift cards. GiftCard is an interface. For this exercise there are 3 types of cards the user can

code that will mimic a collection of Gift cards. GiftCard is an interface. For this exercise there are 3 types of cards the user can enter: GoogleCard, TargetCard and VisaCard. These 3 cards will be classes that implement the GiftCard interface shown below:

GiftCard public double getValue();

In addition to implementing GiftCard, the VisaCard class must have a public method as shown below:

VisaCard public int getFee();

The VisaCard class must have a way to set the fee charged only by Visa cards. The getFee() method will return this fee.

In Main.java, f ini sh the inputCards() method. This method will allow the user to input values needed to c r e a t e any one of the 3 GiftCard implementations. An extra input will be needed to get a VisaCard fee if the user chooses to add a Visa card.

W r i t e a public static method called totCardValMinusFees(). The method must take a List of GiftCard as a parameter and return the total sum of all getValue(). The total must be reduced by the total getFee() of every VisaCard. For instance, assume these 2 cards in the parameter list:

Visa Card: value: 20.0 fee: 1 ---------------- Gift Card value: 5.5

We would expect the return to be (20.0 + 5.5) - 1 = 24.5

See the TODO items in the Main.java template for more clues and directions.

As discussed, use the CardConcrete.java to implement a setValue() and getValue() and implement the GiftCard interface. Google, Target, and VisaCard can inherit from CardConcrete.

image text in transcribed
Current file: Main.java - Load default template... 23 if ("X" . equals(cardType) ) Main.java 24 break; 25 26 cardValue = sc . nextDouble() ; //input + GiftCard.java 27 28 //TODO use cardType to instantiate the c GoogleCard.j... d to determine extra input needed 29 //card value will be the value of the co 30 //TODO, you will need to figure out a wo add a fee if VisaCard is being input 31 VisaCard.java 32 sc. nextLine(); //don't remove, discard input buffer 33 TargetCard.j. 34 //TODO, add the instance created to the 35 36 CardConcrete.. 37 } while(true); //! ("X". equals(inp) ) ); 38 39 //TODO, return the List you created above 40 41 Develop mode Submit mode When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions