Question: Create 4 flow chart one for each process/class. import java.util.Scanner; // First class SingleBurgerCost - without tip public class SingleBurgerCost { public static void main(String[]
Create 4 flow chart one for each process/class.
import java.util.Scanner;
// First class SingleBurgerCost - without tip
public class SingleBurgerCost {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("What type of burger would you like (Vegan or Beef)?: ");
String name = input.next();
if(name.equalsIgnoreCase("Vegan"))
{
Vegan burger = new Vegan();
System.out.println("You have ordered: ");
System.out.println(burger);
}
else if(name.equalsIgnoreCase("Beef"))
{
Burger burger = new Burger();
System.out.println("What type of bread would you like (White or Wheat)?: ");
String bread = input.next();
burger.setBread(bread);
System.out.println("What type of drink would you like (Water or Soda)?: ");
String drink = input.next();
burger.setDrink(drink);
System.out.println("You have ordered: ");
System.out.println(burger);
}
}
}
// Second class Burger
class Burger {
private String type;
private double cost;
private String burger;
private String bread;
private String drink;
public Burger()
{
this.type = "Beef";
this.cost = 6.99; // cost for both vegan and beef burgers
}
public Burger(String type, double cost)
{
this.type = type;
this.cost = cost;
}
public double getCost()
{
return cost;
}
public void setCost()
{
this.cost += 1;
}
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
public String getBread()
{
return bread;
}
public String getDrink()
{
return drink;
}
public void setBread(String bread)
{
this.bread = bread;
}
public void setDrink(String drink)
{
this.drink = drink;
setCost();
}
@Override
public String toString()
{
return getType() + " burger "
+ this.getBread() + " bread" + " "
+ this.getDrink() + "(+ $0.99) " // additional cost for a drink if a beef burger is ordered
+ "A burger cost is $"+ this.getCost();
}
}
// Third class Vegan
class Vegan extends Burger
{
public Vegan()
{
this.setType("Vegan");
setBread();
}
public void setBread()
{
// a vegan burger order comes with wheat bread and a drink
this.setBread("with " + "wheat bread " + "and " + "complimentary drink");
}
@Override
public String toString()
{
return getType() + " burger "+ this.getBread() + " "+ "A burger cost is $"+ this.getCost();
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
