This is Java programing.Modify this Java code,so that each franchise can assign and print their own burger price.The programing have at least three franchises. (Use abstract)
class newBurger {
public newBurger() {
}
public void salmonBurger(){
System.out.println("salmonBurger $5.99");
System.out.println("Kcal: 294");
}
public void clamBurger(){
System.out.println("clamBurger $4.99");
System.out.println("Kcal: 200");
}
public void oysterBurger(){
System.out.println("oysterBurger $3.50");
System.out.println("Kcal: 125");
}
}
class franchise1 extends newBurger {
String name = "franchise #1";
public franchise1() {
}
}
public class burger {
public static void main(String[] args) {
franchise1 menu = new franchise1();
System.out.println(menu.name);
menu.salmonBurger();
menu.clamBurger();
menu.oysterBurger();
}
}
Hi,I modified the java program in such a way that you can use abstract class and also made each franchise as separate class so that each franchise can also include it's individual properties in itself also with the common properties and mandatory properties.
Hope,you will find this code helpful.Any further information regarding this question or concept or any other question .Please feel free to ask us .We will love to help you
abstract class francshise{
void show();
}
class salmonBurger extends francshise{
public void show(){
System.out.println("salmonBurger $5.99");
System.out.println("Kcal: 294");
}
}
class clamBurger extends francshise{
public void show(){
System.out.println("clamBurger $4.99");
System.out.println("Kcal: 200");
}
}
class oysterBurger extends francshise{
public void show(){
System.out.println("oysterBurger $3.50");
System.out.println("Kcal: 125");
}
}
public class burger {
public static void main(String[] args) {
System.out.println("Franchise 1 menu);
salmonBurger sb=new salmonBurger();
sb.show();
clamBurger cb=new clamBurger();
cb.show();
oysterBurger ob=new oysterBurger();
ob.show();
}
}
Get Answers For Free
Most questions answered within 1 hours.