Question
The practice program code is below: import java.util.*; public abstract class Pizza { public enum PizzaSize { MEDIUM, LARGE, XLARGE; } private PizzaSize psize; private
The practice program code is below:
import java.util.*;
public abstract class Pizza {
public enum PizzaSize {
MEDIUM, LARGE, XLARGE;
}
private PizzaSize psize;
private double baseprice;
private List toppings;
public Pizza() {
this.psize = PizzaSize.MEDIUM;
this.baseprice = 0.0;
this.toppings = new LinkedList();
}
public Pizza(PizzaSize size) {
this.psize = size;
this.baseprice = 0.0;
this.toppings = new LinkedList();
}
public void addToppings(String addtoppings) {
this.toppings.add(addtoppings);
double cprice = this.getBaseprice();
cprice += 1.0;
this.setBaseprice(cprice);
}
public void printReceipt() {
System.out.println("Type : " +this.getClass().getSimpleName());
System.out.println("Size : " + this.getPizzaSize().toString());
System.out.println("Toppings : " +Arrays.toString(this.toppings.toArray()));
System.out.println("Receipt : $" +this.getBaseprice());
}
public void setBaseprice(double bp) {
this.baseprice = bp;
}
public double getBaseprice() {
return baseprice;
}
public void setPizzaSlice(PizzaSize size) {
this.psize = size;
}
public PizzaSize getPizzaSize() {
return psize;
}
public void setToppings(List t) {
this.toppings.addAll(t);
}
public List getToppings() {
return toppings;
}
}
import java.util.*;
public class PepperoniPizza extends Pizza {
public enum PExtraToppings{
CHERRY_TOMATO, PARMESAN_CHEESE
}
final double PEPPERONI_BASE_PRICE = 10.00;
final static List PEPPERONI_TOPPINGS = new LinkedList ();
static {
PEPPERONI_TOPPINGS.add("Pepperoni");
PEPPERONI_TOPPINGS.add("Mozarella");
}
public PepperoniPizza () {
super();
setBaseprice(PEPPERONI_BASE_PRICE);
setToppings(PEPPERONI_TOPPINGS);
}
public PepperoniPizza(PizzaSize ppsize) {
super(ppsize);
setBaseprice(PEPPERONI_BASE_PRICE);
setToppings(PEPPERONI_TOPPINGS);
}
@Override
public void addToppings(String etoppings) {
super.addToppings(etoppings);
}
}
(Lab-7 tasks must be submit in icollege due on March o7th 2018) Create Program as same as your Practice Program. 1. Create Main.java as follows *UNCOMMENT FOR YOUR HOMEWORK * Scenario I: * 1. Create a polymorphic object of type ChickenWings * 2. Add 15 wings to it 3. Print receipt 4. Add 1 sauce to it 5, Print receipt (again) *Scenario II * 1. Create a polymorphic object of type ChickenWings *2. Add 20 wings to it * 3. Print receipt * 4. Add a free item (e.g., onion rings) * 5. Add 3 sauce 5, Print receipt (again) (Lab-7 tasks must be submit in icollege due on March o7th 2018) Create Program as same as your Practice Program. 1. Create Main.java as follows *UNCOMMENT FOR YOUR HOMEWORK * Scenario I: * 1. Create a polymorphic object of type ChickenWings * 2. Add 15 wings to it 3. Print receipt 4. Add 1 sauce to it 5, Print receipt (again) *Scenario II * 1. Create a polymorphic object of type ChickenWings *2. Add 20 wings to it * 3. Print receipt * 4. Add a free item (e.g., onion rings) * 5. Add 3 sauce 5, Print receipt (again)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started