Question: 1. Create three (2) classes named Party, Dinner Party, and DemoParty. 2. In the Party class, declare a private variable of int type named numGuests.

1. Create three (2) classes named Party, Dinner Party, and DemoParty.

2. In the Party class, declare a private variable of int type named numGuests.

3. Create a getter method named getNumGuests() that will allow you to retrieve the value of numGuests.

4. Create a setter method named setNumGuests() with an int parameter named num. In this method, assign num to numGuests.

5. Create a method named showInvitation() that prints"Please come to my party!".

6. Your Dinner Party class should extend the Party class. In the Dinner Party class, declare a private variable of int type named foodChoice.

7. Create a getter method named getFoodChoice() that will allow you to retrieve the value of foodChoice.

8. Create a setter method named setFoodChoice() with an int parameter named choice. In this method, assign choice to foodChoice.

9. Create a showlnvitation() method that overrides the method in the parent class. This method shall print "Please come to my dinner party!".

10. Code the Demo Party class to produce an output similar to the example below.

Sample Output: Enter the number of guests for the dinner party: 30

Sample Output: Enter the number of guests for the dinner party: 30 Enter the menu option (1 for chicken or 2 for beef): 1 The dinner party has 30 guests. Menu option 1 will be served. Please come to my dinner party!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a basic implementation of the described classes in Java java import javautilScanner class Part... View full answer

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 Programming Questions!