Question: After the project opens, expand the Project Tree for the project. Right click on the package node for the project and select New - -

After the project opens, expand the Project Tree for the project. Right click on the package node for the project and select New --> Java Class... to add the following to the project:
A. An abstract class called Beverage. This abstract class is the base class for the other classes in the program. The parameterized constructor should be protected (rather than public) since it should only be accessible from subclasses. The accessor methods and toString() method should be the same as the Beverage class from the first assignment.
B. Add the Coffee and Tea classes that extend the abstract Beverage base class.
C. Declare an interface named PaymentMethod by right clicking on the package for the package and selecting New and then Java Interface... The interface should include a public method named processPayment() that takes a double as its parameter and returns a boolean. (The parameter represents the amount of the payment, and the boolean represents whether the payment was successful or not).
D. Declare a CreditCard class that implements the PaymentMethod interface. This class should have a String attribute for the credit card number and a parameterized constructor that sets the value of the credit card number. The overridden processPayment() method should print out a message that the payment was successful and return true (since there isn't really a way to process the payment).
E. Declare a Cash class that implements the PaymentMethod interface. This class should have a double attribute for the amount tendered and a parameterized constructor that sets the value of this attribute. The overridden processPayment() method should print out the amount tendered, print the change due, and then return true.
F. Study the Order class and note how it makes use of the classes that inherit from the abstract Beverage class and those that implement the PaymentMethod interface. In the main() method in the DrinkOrderAbstract class, construct 2 Order objects. Use the Order class's add() method to add up to 5 Coffee or Tea objects to each order. Use the Order class's setPayment() method to add a credit card payment to one order and a cash payment to the other. For each order, print out the list of drinks in the order, the total price for the order, and the payment. The exact output will vary, but the result should look something like this:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!