Question: a. Create a class named Pizza with a String array data field that can hold the names of up to 10 pizza toppings. Also include

a. Create a class named Pizza with a String array data field that can hold the names of up to 10 pizza toppings. Also include a field for the price. Include a constructor that takes two parameters: the array of toppings and the number of toppings stored in the list. The constructor creates a String description from the list of toppings, adding a comma between each topping. It also sets the price at $14 plus $2 for each topping. Include a toString() method to display the Pizza description and price. Save the file as Pizza.java.

b. Create a subclass named DeliveryPizza that inherits from Pizza but adds a numeric delivery fee and a String delivery address. The constructors parameters include the array of toppings, the delivery address, and the number of toppings. The delivery fee is $3 if the Pizza ordered costs more than $18; otherwise, the delivery fee is $5. Save the file as DeliveryPizza.java.

c. Write an application that prompts the user for topping values for a Pizza. Allow the user to continually enter toppings until entering a QUIT constant or reaching 10 toppings. Also ask the user whether the Pizza is to be delivered. If the Pizza is to be delivered, prompt the user for the delivery address and construct a DeliveryPizza object; otherwise, construct a Pizza object. Then, display all the values for the Pizza. Save the file as DemoPizza.java.

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!