Question

JAVA

Hello, I would like some help wiht this program, I'm not sure hard to code the deep copy and array for MenuSchedule

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

Here is my code:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//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);

       }

}

//end of MenuItem.java

//MenuSchedule.java

package Menu;

public class MenuSchedule {

      

       //private variables

      

       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;

       }

      

       // return weekday

       public String getWeekday()

       {

             return weekday;

       }

      

       // @param weekday to set

       public void setWeekday(String weekday)

       {

             this.weekday = weekday;

       }

      

       // return soup

       public MenuItem getSoup()

       {

             return soup;

       }

      

       // @param soup to set

       public void setSoup(MenuItem soup)

       {

             this.soup = soup;

       }

      

       // return salad

       public MenuItem getSalad()

       {

             return salad;

       }

            

       // @param salad to set

       public void setSalad(MenuItem salad)

       {

             this.salad = salad;

       }

      

       // return entree

       public MenuItem getEntree()

       {

             return entree;

       }

            

       // @param soup to set

       public void setEntree(MenuItem entree)

       {

             this.entree = entree;

       }

      

       // return desert

       public MenuItem getDesert()

       {

             return desert;

       }

            

       // @param soup to set

       public void setDesert(MenuItem desert)

       {

             this.desert = desert;

       }

      

       //return Totaltime

       public int getTotaltime()

       {

             return Totaltime;

       }

      

       // @param Totaltime to set

       public void setTotaltime(int Totaltime)

       {

             this.Totaltime = Totaltime;

       }

      

       // return Totalprice

       public double getTotalprice()

       {

             return Totalprice;

       }

      

       // @param Totalprice to set

       public void setTotalprice(double Totalprice)

       {

             this.Totalprice = Totalprice;

       }

      

       @Override

       public String toString()

       {

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

                           +soup+"\n"+salad+"\n"+entree+"\n"+desert+"\n------------------------------------------------------------------\n"

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

       }

      

      

}

//end of MenuSchedule.java

// MenuScheduleImplement.java : Implement the MenuSchedule and MenuItem class

package Menu;

public class MenuScheduleImplement {

       public static void main(String[] args) {

            

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

            

             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("Suday",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<3;i++)

             {

                    menuSchedule[i].setTotaltime(menuSchedule[i].getSoup().getTime()+menuSchedule[i].getSalad().getTime()+menuSchedule[i].getEntree().getTime()

                                 +menuSchedule[i].getDesert().getTime());

                    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();

             }

       }

}

//end of MenuScheduleImplement.java

Output:

FRIDAY Lemon Cauliflower Cranberry Walnut Grilled Salman with Asparagus Creme Brulee 30 min $7.95 5 min 25 min $19.95 45 min %7.9!5 $9.95 Total 105 min $45.80 SATURDAY Roasted Red Pepper Bisque Dandelion with Strawberries Pasta Primavera Flourless Chocolate cake with Raspberry Sauce 25 min 8.95 5 min 20 min $14.95 50 min $7.95 $11.95 Total 100 min $43.80 SUDAY Lobster Bisque Tomato, Basil and Mozzarella Sweet Potato Lasagna Assorted Biscotti 30 min $12.95 5 min 60 min $18.95 40 min $5.9!5 $9.95 Total 135 min 47.80

Add a comment
Know the answer?
Add Answer to:
JAVA Hello, I would like some help wiht this program, I'm not sure hard to code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVASCRIPT/JQUERY Hello I would like some help understanding jQuery. Here are the directions: Write a program...

    JAVASCRIPT/JQUERY Hello I would like some help understanding jQuery. Here are the directions: Write a program that creates the following table: Course Course Name Day Time IMS115 Windows 10 Monday 6 PM IMS215 Office 2016 Wednesday 5 PM MIS200 Java Thursday 9 AM MTH105 Business Math Saturday 10 AM Using jQuery, select every other odd row and change the font color to blue and make it bold. And here is my code: Chapter4.html <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="Chapter4.css">...

  • Hello Ive been tryting to add the CDN of jquery to my html code and I...

    Hello Ive been tryting to add the CDN of jquery to my html code and I keep getting an error Need help with this : ​​ Navigate to www.code.jquery.com in your Chrome browser. On this page, you'll find different stable versions of jQuery. Select uncompressed for jQuery Core 3.3.1. Copy the <script> tag that is given to you. In store_hours.html, paste that tag directly above your body's closing tag. This is the jQuery CDN. After you paste this code into...

  • Hello, I have some errors in my C++ code when I try to debug it. I...

    Hello, I have some errors in my C++ code when I try to debug it. I tried to follow the requirements stated below: Code: // Linked.h #ifndef INTLINKEDQUEUE #define INTLINKEDQUEUE #include <iostream> usingnamespace std; class IntLinkedQueue { private: struct Node { int data; Node *next; }; Node *front; // -> first item Node *rear; // -> last item Node *p; // traversal position Node *pp ; // previous position int size; // number of elements in the queue public: IntLinkedQueue();...

  • JAVA Hello I am trying to add a menu to my Java code if someone can...

    JAVA Hello I am trying to add a menu to my Java code if someone can help me I would really appreacite it thank you. I found a java menu code but I dont know how to incorporate it to my code this is the java menu code that i found. import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; public class MenuExp extends JFrame { public MenuExp() { setTitle("Menu Example");...

  • How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the use...

    How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the user to input the following. ○ How many apples are on hand ○ How many apples should be in stock ○ How many oranges are on hand ○ How many oranges should be in stock  Perform an operation to determine how many of...

  • Hello, I was wondering if you could possibly think of ways to improve my home page then I would l...

    Hello, I was wondering if you could possibly think of ways to improve my home page then I would like you to do so. I know it could be better. Thank you. index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Untitled Document</title> <!-- Bootstrap --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <!-- jQuery library --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!-- Latest compiled JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> <link href="style.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> <header> <nav class="navbar...

  • I'm need help in the Pacific Trails section of the assignment. I posted my chapter 2...

    I'm need help in the Pacific Trails section of the assignment. I posted my chapter 2 assignment on the bottom of the picture. I'm using Notepad++. This was the previous assignment: CHAPTER 2 ASSIGMENT paste the first content to index.html file and second to yurts.html. First: (index.html contents are below) <!DOCTYPE html> <head> <title>Pacific Trails Resorts</title> </head> <style> a{    padding-right:14px; /* padding anchor tage to right 15px for nav menu */ } </style> <body> <header> <h1>Pacific Trails Resort</h1>   ...

  • i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due...

    i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...

  • Hello, i need help with this homework: Code provided: public class DirectedWeightedExampleSlide18 { public static void...

    Hello, i need help with this homework: Code provided: public class DirectedWeightedExampleSlide18 { public static void main(String[] args) { int currentVertex, userChoice; Scanner input = new Scanner(System.in); // create graph using your WeightedGraph based on author's Graph WeightedGraph myGraph = new WeightedGraph(4); // add labels myGraph.setLabel(0,"Spot zero"); myGraph.setLabel(1,"Spot one"); myGraph.setLabel(2,"Spot two"); myGraph.setLabel(3,"Spot three"); // Add each edge (this directed Graph has 5 edges, // so we add 5 edges) myGraph.addEdge(0,2,9); myGraph.addEdge(1,0,7); myGraph.addEdge(2,3,12); myGraph.addEdge(3,0,15); myGraph.addEdge(3,1,6); // let's pretend we are on...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT