Problem Status public alass Printenu extends Mena Burger211 company has three fr
ID: 3877918 • Letter: P
Question
Problem Status public alass Printenu extends Mena Burger211 company has three franchises. (Bellevue, Seattle and Everett) /The constructer whan you create the object, sets the prices, tha franchise nano then print the nonu Burger211 sells 3 burgers (classBurger, overridingBurger constructorBurger) . Each franchise has to display the same style (format) of menu at their shops. .All 3 burgers have a name and Kcal value. This info can not be changed by any PzintMenu (String name, double burgerPricel, double burgexPrioe2, double bugerPrice3) ouper.EranchiseNano nane this.price (buzgerPricel, burgerPrice2, burgerPrice3) franchise .Only the price of the burgers can be decided/changed by each franchise. .Menu contains the franchise name, all 3 burger names, their Kcal values, and their auper-printMena0 Sets the price for the Super Nena elass override public vold price (double burgerPricel, double burgerFrioe2, double prices burgerPrice3) Your Mission Develop a java system for the Burger211(Text Version) abstract class and constructor are minimum requirement .Your final submission a one super class (java) a one sub class (java) public elass franchise one Main program (java) public static void main (String[) arga) abstract class Menu[ PrintMenu bellevue-new PrintMenu("Bellevue",5.99, 4.75, 3.00) //Instances Declaration: franchieameburger name, price, Cal String franchiseName: //sets the burger into public void burgerInfoD // burgerNanel -"elasurger" //Prints the menu public woid printMenu burgerInto yston.out.printinO ystem.out.println" /abatract method, only thing that changes besides the franchiseName public abstract void price (double pricel, double price2, double price3)Explanation / Answer
Ans :)
//Abstract Class
public abstract class Menu {
public String franchisName;
public String burgerName1;
public String burgerName2;
public String burgerName3;
public double kcal1;
public double kcal2;
public double kcal3;
public double price1;
public double price3;
public double price2;
public void burgerInfo(){
burgerName1="classBurger";
burgerName2="overriddingBurger";
burgerName3="constructorBurger";
kcal1=1;
kcal2=2;
kcal3=3;
}
//prints the menu
public void printMenu(){
burgerInfo();
System.out.println();
System.out.println("************************************");
System.out.println("Franchise Name : "+franchisName);
System.out.println("1. Burger Name : "+burgerName1+" and Kcal Value is "+kcal1+" and the price is :"+price1);
System.out.println("2. Burger Name : "+burgerName2+" and Kcal Value is "+kcal2+" and the price is :"+price2);
System.out.println("3. Burger Name : "+burgerName3+" and Kcal Value is "+kcal3+" and the price is :"+price3);
}
public abstract void price(double price1,double price2,double price3);
}
// sub class
public class PrintMenu extends Menu{
public PrintMenu(String name,double price1,double price2,double price3) {
super.franchisName=name;
this.price(price1, price2, price3);
super.printMenu();
}
@Override
public void price(double price1, double price2, double price3) {
// TODO Auto-generated method stub
super.price1=price1;
super.price2=price2;
super.price3=price3;
}
}
//Main class
public class Franchise {
public static void main(String[] args) {
PrintMenu pm=new PrintMenu("Bellevue", 5.99, 4.75, 3.00);
}
}
Explanation : check the above code as per your requirements, and one is abstract class(i.e, Menu.java) , 2nd one is sub class(i.e, PrintMenu) and Main class is Franchise.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.