chapter 10 case problem 1.a In Chapter 8, you created an Event class for Carly’s
ID: 3702165 • Letter: C
Question
chapter 10 case problem 1.a
In Chapter 8, you created an Event class for Carly’s Catering. Now extend the class to create a DinnerEvent class. In the extended class, include four new integer fields that represent numeric choices for an entre?e, two side dishes, and a dessert for each DinnerEvent object. Also include three final arrays that contain String menu options for entre?es, side dishes, and desserts, and store at least three choices in each array. Create a DinnerEvent constructor that requires arguments for an event number and number of guests, and integer menu choices for one entre?e, two side dishes, and one dessert. Pass the first two parameters to the Event constructor, and assign the last four parameters to the appropriate local fields. Also include a getMenu() method that builds and returns a String including the Strings for the four menu choices. Save the file as DinnerEvent.java.
Explanation / Answer
Explanation: Below is the Java code for above problem with proper description provided within comments itself. Below code some sample output screenshots are attached. You should provide Event class which have to extend. But now i created Event class also as per need. If you need any other help for this Comment me below. Thanks Java code : // new DinnerEvent class public class DinnerEvent extends Event { // four int variables int entree; int dish1; int dish2; int dessert; // final 3 arrays have atleast 3 values final String[] entrees = { "Entree1", "Entree2", "Entree3" }; final String[] dishes = { "dish1", "dish2", "dish3" }; final String[] desserts = { "dessert1", "dessert2", "dessert3" }; // constructor public DinnerEvent(int eventNo, int numberOfguests, int menuOption, int entree, int dish1, int dish2, int dessert) { // pass to Event class constructor super(eventNo, numberOfguests, menuOption); this.entree = entree; this.dish1 = dish1; this.dish2 = dish2; this.dessert = dessert; } // getMenu option // you can create your menu as you want public String getMenu() { return " Menu 1. Entree 2. Dish1 3. Dish2 4. Dessert"; } } // You are not provide event class // this class created by me for calling constructor by drived class public class Event { // variables int eventNo; int numberOfguests; int menuOption; // constructor public Event(int eventNo, int numberOfguests, int menuOption) { super(); this.eventNo = eventNo; this.numberOfguests = numberOfguests; this.menuOption = menuOption; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.