Question: I need help writing these class definitions for my Java class. I think I have the FoodDish class definition figured out, but am struggling with

I need help writing these class definitions for my Java class. I think I have the FoodDish class definition figured out, but am struggling with the ArrayLists in Menu. Instructions from my class below:

Create a new project in BlueJ. Create two new classes in the project, with the following specifications:

Class name: FoodDish

Fields:

  • name (String)
  • description (String)
  • calories (int)

1 Constructor: takes parameters with the same name as the fields and uses them to initialize the fields (use 'this')

Methods: Write getters and setters for all fields. The getters and setters should be named according to standard Java conventions. Add validation to setCalories so that the calories cannot be set to a negative value.

Class name: Menu

Fields:

  • name (String)
  • appetizers (ArrayList)
  • entrees (ArrayList)

Constructor: takes one parameter, the name, and initializes the name field; creates two empty lists to initialize the other two fields.

Methods: Write getters and setters for all fields. Name the getters and setters according to standard Java conventions. Add validation to setAppetizers and setEntrees so that the field cannot be set to 'null'.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!