Assignment 2
Assignment 2
Department of CSIT
Due - 29th Mar 2020, 11.55 PM
Max Marks – 30 (Weightage out of 100 is 20%)
Policy: Solve the programs as per instructions given in each question. Use the basic template with
comments is being shown by the instructor in each problem definition. Export the project in archive
format before submitting.
Problem. Write a program that computes the cost of choosing a pizza using Object Oriented
Programming. Must use the template given below. [30 Marks]
import java.util.ArrayList;
// Price of Small, medium and large pizza is 10$, 12$ and 14$ respectively.
this.type = type;
this.size = size;
}
/* Generate Setters and getters for the variables which you will be
requiring later [3 Marks] */
}
// Change, if required with inheritance and interface. [Inherit pizza and
implement the interface] [2 Marks]
/*Define the toppings here, ask the user, max 2 toppings allowed for Regular type
pizza. Populate your ArrayList of Toppings defined in Pizza class in here. Also
compute here the total cost of ordering the extra toppings. [3 Marks] */
@Override
public void getToppings() {
/*Implement the PizzaPrice Interface’s methods here to find the price of each
pizza by its size using the cost of toppings. One of the method is implemented for
your reference. [3 Marks] */
@Override
public double PriceofSmallPizza(double costTopping) {
// TODO Auto-generated method stub
return costTopping+this.getPriceOfBasePizza ()[0];
}
}
// Change, if required with inheritance and interface. [Inherit pizza and
implement the interface] [2 Marks]
/*Define the toppings here, ask the user, max 3 toppings allowed for Feast type
pizza. Populate your ArrayList of Toppings defined in Pizza class in here. Also
compute here the total cost of ordering the extra toppings. [3 Marks] */
@Override
public void getToppings() {
/*Implement the PizzaPrice Interface’s methods here to find the price of each
pizza by its size using the cost of toppings. One of the method is implemented for
your reference. [3 Marks] */
@Override
public double PriceofSmallPizza(double costTopping) {
// TODO Auto-generated method stub
return costTopping+this.getPriceOfBasePizza ()[0];
}
}
import java.util.Scanner;
/* Find total price of pizza as per selection of the user for each pizza type.
[5 Marks] */
if (type.equalsIgnoreCase("regular")){
}
if(type.equalsIgnoreCase()){
/* Finally call the toString() method from your Pizza Class and modify it to
display the customer name, their type, size and toppings and the total cost of the
pizza. [2 Marks] */