Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Hello I would like some help fixing my code, there has to be only two classes MenuItem.java MenuSchedule.java my main issue is that the

Java

Hello I would like some help fixing my code, there has to be only two classes MenuItem.java MenuSchedule.java

my main issue is that the array is not working

here are the instructions:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Here is is in text form:

MenuItem.java

package Menu;

public class MenuItem {

private String itemname;

private int time;

private double price;

// default constructor

public MenuItem()

{}

//3-parameter constructor

public MenuItem(String n, int t, double p)

{

itemname =n;

time = t;

price = p;

}

//copy constructor

public MenuItem(MenuItem existing)

{

itemname = existing.itemname;

time =existing.time;

price = existing.price;

}

// returns itemname

public String getItemname()

{

return itemname;

}

//@param itemname the itemname to set

public void setItemname(String itemname)

{

this.itemname = itemname;

}

// returns time

public int getTime()

{

return time;

}

// @param time to set

public void setTime(int time)

{

this.time = time;

}

// returns price

public double getPrice()

{

return price;

}

// @param price to set

public void setPrice(double price)

{

this.price = price;

}

@Override

public String toString()

{

return String.format("%1$-50s", itemname)+

String.format("%1$-10s", time+ " min")+

String.format("$%-10.2f", price);

}

}

MenuSchedule.java

package Menu;

public class MenuSchedule {

//private variables

public static void main(String[] args) {

}

private String weekday;

private MenuItem soup;

private MenuItem salad;

private MenuItem entree;

private MenuItem desert;

private int Totaltime;

private double Totalprice;

//default constructor

public MenuSchedule()

{

weekday = "";

soup = new MenuItem();

salad = new MenuItem();

entree = new MenuItem();

desert = new MenuItem();

Totaltime = 0;

Totalprice = 0;

}

//5-parameter constructor

public MenuSchedule(String w, MenuItem sp, MenuItem sd, MenuItem e, MenuItem d)

{

weekday = w;

soup =new MenuItem(sp);

salad =new MenuItem(sd);

entree = new MenuItem(e);

desert = new MenuItem(d);

Totaltime = 0;

Totalprice = 0;

}

//copy constructor

public MenuSchedule(MenuSchedule existing)

{

weekday = existing.getWeekday();

soup = new MenuItem(existing.getSoup());

salad = new MenuItem(existing.getSalad());

entree = new MenuItem(existing.getEntree());

desert = new MenuItem(existing.getDesert());

Totaltime = 0;

Totalprice = 0;

}

public String getWeekday()

{

return weekday;

}

public void setWeekday(String weekday)

{

this.weekday = weekday;

}

public MenuItem getSoup()

{

return soup;

}

public void setSoup(MenuItem soup)

{

this.soup = soup;

}

public MenuItem getSalad()

{

return salad;

}

public void setSalad(MenuItem salad)

{

this.salad = salad;

}

public MenuItem getEntree()

{

return entree;

}

public void setEntree(MenuItem entree)

{

this.entree = entree;

} public MenuItem getDesert()

{

return desert;

}

public void setDesert(MenuItem desert)

{

this.desert = desert;

}

public int getTotaltime()

{

return Totaltime;

}

public void setTotaltime(int Totaltime)

{

this.Totaltime = Totaltime;

}

public double getTotalprice()

{

return Totalprice;

}

public void setTotalprice(double Totalprice)

{

this.Totalprice = Totalprice;

}

MenuSchedule menuSchedule[]; // for the 3 weekdays menuSchedule = new MenuSchedule[3];

menuSchedule[0] = new MenuSchedule("Friday",new MenuItem("Lemon Cauliflower",30,7.95), new MenuItem("Cranberry Walnut",5,9.95), new MenuItem("Grilled Salman with Asparagus",25,19.95), new MenuItem("Creme Brulee",45,7.95));

menuSchedule[1] = new MenuSchedule("Saturday",new MenuItem("Roasted Red Pepper Bisque",25,8.95), new MenuItem("Dandelion with Strawberries",5,11.95), new MenuItem("Pasta Primavera",20,14.95), new MenuItem("Flourless Chocolate cake with Raspberry Sauce",50,7.95));

menuSchedule[2] = new MenuSchedule("Sunday",new MenuItem("Lobster Bisque",30,12.95), new MenuItem("Tomato, Basil and Mozzarella",5,9.95), new MenuItem("Sweet Potato Lasagna",60,18.95), new MenuItem("Assorted Biscotti",40,5.95));

for(int i=0;i

menuSchedule[i].setTotalprice(menuSchedule[i].getSoup().getPrice()+menuSchedule[i].getSalad().getPrice()+ menuSchedule[i].getEntree().getPrice() +menuSchedule[i].getDesert().getPrice());

System.out.println(menuSchedule[i]); System.out.println(); }

@Override

public String toString()

{

return(weekday.toUpperCase())+" ------------------------------------------------------------------ "

+soup+" "+salad+" "+entree+" "+desert+" ------------------------------------------------------------------ "

+String.format("%1$-50s", "Total")+String.format("%1$-10s", Totaltime+" min")+String.format("$%-10.2f", Totalprice);

} Thank you

Chez Moraine, a fake restaurant known for fine dining at reasonable prices, has hired you to develop a program to manage their menu during peak times: Friday, Saturday, and Sunday nights Below is the UML diagram you will implement. You may also use my specs on the next page as your guide to building your classes -double pce Code the following two classes: Menultem and MenuSchedule (an aggregate). See next page for specs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain budgetary Control

Answered: 1 week ago

Question

Solve the integral:

Answered: 1 week ago

Question

What is meant by Non-programmed decision?

Answered: 1 week ago

Question

What are the different techniques used in decision making?

Answered: 1 week ago