Question: Create a new project in BlueJ. Create two new classes in the project, with the following specifications: Class name: FoodDish Fields : name (String) description
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
Get step-by-step solutions from verified subject matter experts
