Question: Java Object Oriented Programming QUESTION 2 (30 MARKS) HyppPizza is developing a system to manage their online pizza ordering. They are different compared to others

Java Object Oriented Programming
Java Object Oriented Programming QUESTION 2 (30 MARKS) HyppPizza is developing a
system to manage their online pizza ordering. They are different compared to
others because they allow the customers to set their pizza size. Given
the following superclass and subclasses: public abstract class Pizza protected String customerId;

QUESTION 2 (30 MARKS) HyppPizza is developing a system to manage their online pizza ordering. They are different compared to others because they allow the customers to set their pizza size. Given the following superclass and subclasses: public abstract class Pizza protected String customerId; protected String toppingName; // topping name protected double topping Price; // per square inch //Methods: //constructors, accessor, toString() abstract double calcPrice (); public class Round Pizza extends Pizza private int diameter; // diameter in inch private boolean cheeseCrust; //true or false //Methods: //constructors, accessor, toString() public double calcPrice () public class SquarePizza extends Pizza private String thickness; // normal, thin private String length; // length in inch //Methods: //constructors, accessor, toString() public double calcPrice () {...) a) Write the following method definition: Normal constructor for both subclasses. (6 marks) ii) Implement the method named calcPrice () for both subclasses that calculate and return the pizza's price based on the following information: The price for Round Pizza is calculated based on the size using the following formula: price pizza area * toppingPrice The pizza area is calculated using the following formula: pizza area = 3.142 + (diameter/2) + (diameter/2) if the customer choose cheese crust, add extra cost for the crust using the following formula: cheese crust = (2 * 3.142 * (diameter/2)) / 2 * 0.50 For the Square Pizza, calculate the price using the following formula: price = length * length toppingPrice If the customers choose a thin pizza, reduce the price by 10%. (9 marks) b) Write fragment codes in the main application that perform the following tasks using the polymorphism concept: 1) Declare an array of objects with the type of Pizza named pizzas with a size of 200. (1 marks) ii) Calculate the average diameter of Round Pizza and the average length of Square Pizza (6 marks) ii) Print details of Round Pizza order with a cheese crust. (4 marks) iv) Count and print the number of pizza with a price of RM15.00 and above, and topping name of "Classified Chicken". (4 marks)

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!