SlideShare a Scribd company logo
How to create an array restaurant menu out of the main class using methods, mutators, accessors,
constructors and objects in Java.
Solution
/** * @fileName :Restaurant.java * @author * @since 10-02-2017 **/ package restaurant;
public class Restaurant { public static void main(String[] args) { //creating array of menu
Menu[] menu =new Menu[4]; //creating 4 menu object Menu item1 = new
Menu("Corn Soup",10.0f,true); Menu item2 = new Menu("bread",20.0f,true); Menu
item3 = new Menu("Chicken roll",80.0f,false); Menu item4 = new
Menu("fish",60.0f,true); //assigning the items to menu array menu[0]=item1;
menu[1]=item2; menu[2]=item3; menu[3]=item4; } } class Menu{ private
String itemName; private float price; private boolean veg; /** * this is default
constructor */ public Menu() { itemName=""; price=0.0f; veg=false; }
/** * * @param itemName * @param price * @param veg */ public
Menu(String itemName, float price, boolean veg) { this.itemName = itemName;
this.price = price; this.veg = veg; } public String getItemName() { return
itemName; } public void setItemName(String itemName) { this.itemName =
itemName; } public float getPrice() { return price; } public void setPrice(float
price) { this.price = price; } public boolean isVeg() { return veg; } public
void setVeg(boolean veg) { this.veg = veg; } }

More Related Content

PDF
Hello everyone,Im working on my fast food order project program..pdf
PDF
Hello everyone,Im actually working on a fast food order program..pdf
PDF
MenuItemvpublic class MenuItem .pdf
PDF
public class FullListException extends Exception { Default .pdf
PDF
Architecture - Part 2.pdf
DOCX
project_additionsCuisineType.javaproject_additionsCuisineType..docx
PDF
Lo37
PDF
Hello everyone,Im working on my fast food order project program..pdf
Hello everyone,Im actually working on a fast food order program..pdf
MenuItemvpublic class MenuItem .pdf
public class FullListException extends Exception { Default .pdf
Architecture - Part 2.pdf
project_additionsCuisineType.javaproject_additionsCuisineType..docx
Lo37

More from manjan6 (20)

PDF
An introduction and explanation of human factors and sociotechnical .pdf
PDF
Astronomers were able to find a new planet in a far away solar system.pdf
PDF
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
PDF
All of the following individuals are U.S. residents Kelly (27.pdf
PDF
Blossom Company had these transactions during the current period..pdf
PDF
Using the case study below, develop a written report of your market .pdf
PDF
Which of the following is NOT a characteristic of a plasmid used as .pdf
PDF
What is the evolutionary significance of the amniotic egg Solut.pdf
PDF
What is the role of HTTP What types of objects are transmitted in H.pdf
PDF
What is the difference between a hash in perl and a hashtable in Jav.pdf
PDF
What are the specific linkages among immune surveillance, clonal sel.pdf
PDF
True or False –Paraeducators provide direct or indirect instructio.pdf
PDF
The situation where the few who yell the loudest get heard Is ref.pdf
PDF
Templated Binary Tree implementing function help I need to im.pdf
PDF
State if you agree or disagree with the question and comments made b.pdf
PDF
A number of benefits that one might expect to see from using a datab.pdf
PDF
QUESTION If you look at the code, youll see that we keep two list.pdf
PDF
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
PDF
Please help with this. program must be written in C# .. All of the g.pdf
PDF
Match the enzyme activity in DNA synthesis with its function. DNA po.pdf
An introduction and explanation of human factors and sociotechnical .pdf
Astronomers were able to find a new planet in a far away solar system.pdf
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
All of the following individuals are U.S. residents Kelly (27.pdf
Blossom Company had these transactions during the current period..pdf
Using the case study below, develop a written report of your market .pdf
Which of the following is NOT a characteristic of a plasmid used as .pdf
What is the evolutionary significance of the amniotic egg Solut.pdf
What is the role of HTTP What types of objects are transmitted in H.pdf
What is the difference between a hash in perl and a hashtable in Jav.pdf
What are the specific linkages among immune surveillance, clonal sel.pdf
True or False –Paraeducators provide direct or indirect instructio.pdf
The situation where the few who yell the loudest get heard Is ref.pdf
Templated Binary Tree implementing function help I need to im.pdf
State if you agree or disagree with the question and comments made b.pdf
A number of benefits that one might expect to see from using a datab.pdf
QUESTION If you look at the code, youll see that we keep two list.pdf
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
Please help with this. program must be written in C# .. All of the g.pdf
Match the enzyme activity in DNA synthesis with its function. DNA po.pdf
Ad

Recently uploaded (20)

PDF
TR - Agricultural Crops Production NC III.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
master seminar digital applications in india
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Types and Its function , kingdom of life
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
TR - Agricultural Crops Production NC III.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
master seminar digital applications in india
STATICS OF THE RIGID BODIES Hibbelers.pdf
Basic Mud Logging Guide for educational purpose
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Renaissance Architecture: A Journey from Faith to Humanism
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
Anesthesia in Laparoscopic Surgery in India
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Pharma ospi slides which help in ospi learning
Cell Types and Its function , kingdom of life
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPH.pptx obstetrics and gynecology in nursing
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Ad

How to create an array restaurant menu out of the main class using m.pdf

  • 1. How to create an array restaurant menu out of the main class using methods, mutators, accessors, constructors and objects in Java. Solution /** * @fileName :Restaurant.java * @author * @since 10-02-2017 **/ package restaurant; public class Restaurant { public static void main(String[] args) { //creating array of menu Menu[] menu =new Menu[4]; //creating 4 menu object Menu item1 = new Menu("Corn Soup",10.0f,true); Menu item2 = new Menu("bread",20.0f,true); Menu item3 = new Menu("Chicken roll",80.0f,false); Menu item4 = new Menu("fish",60.0f,true); //assigning the items to menu array menu[0]=item1; menu[1]=item2; menu[2]=item3; menu[3]=item4; } } class Menu{ private String itemName; private float price; private boolean veg; /** * this is default constructor */ public Menu() { itemName=""; price=0.0f; veg=false; } /** * * @param itemName * @param price * @param veg */ public Menu(String itemName, float price, boolean veg) { this.itemName = itemName; this.price = price; this.veg = veg; } public String getItemName() { return itemName; } public void setItemName(String itemName) { this.itemName = itemName; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public boolean isVeg() { return veg; } public void setVeg(boolean veg) { this.veg = veg; } }