public class Party {
private int guests;
/**
* return the guests
*/
public int getGuests() {
return guests;
}
/**
* param guests
* the guests to set
*/
public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation() {
System.out.println(\"Please come to my party\");
}
}
import java.util.Scanner;
public class UseParty {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
Scanner keyboard = new Scanner(System.in);
System.out.print(\"Enter number of guests for the party.>>\");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println(\"The party has \" + aParty.getGuests() + \" guest\");
aParty.displayInvitation();
}
}
public class DinnerParty extends Party {
private int dinnerChoice;
/**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
}
import java.util.Scanner;
public class UseDinnerParty {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
int choice;
Scanner keyboard = new Scanner(System.in);
DinnerParty aDinnerParty = new DinnerParty();
System.out.print(\"Enter number of guests for the party.>>\");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println(\"The party has \" + aParty.getGuests() + \" guest\");
aParty.displayInvitation();
System.out.print(\"Enter number of guests for the dinner party>> \");
guests = keyboard.nextInt();
aDinnerParty.setGuests(guests);
System.out
.print(\"Enter the menu option-1 for children or 2 for beef >> \");
choice = keyboard.nextInt();
aDinnerParty.setDinnerChoice(choice);
System.out.println(\"The dinner party has \" + aDinnerParty.getGuests());
System.out.println(\"menu option \" + aDinnerParty.getDinnerChoice()
+ \" will be served\");
aDinnerParty.displayInvitation();
}
}
public class DinnerParty2 extends Party {
private int dinnerChoice;
/**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
public void displayInvitation() {
System.out.println(\"Please come to my dinner party\");
}
}
import java.util.Scanner;
public class UseDinnerParty2 {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
int choice;
Scanner keyboard = new Scanner(System.in);
DinnerParty2 aDinnerParty = new DinnerParty2();
System.out.print(\"Enter number of guests for the party.>>\");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println(\"The party has \" + aParty.getGuests() + \" guest\");
aParty.displayInvitation();
System.out.print(\"Enter number of guests for the dinner party>> \");
guests = keyboard.nextInt();
aDinnerParty.setGuests(guests);
System.out
.print(\"Enter the menu option-1 for children or 2 for beef >> \");
choice .
public class Party { private int guests; return .pdf
1. public class Party {
private int guests;
/**
* return the guests
*/
public int getGuests() {
return guests;
}
/**
* param guests
* the guests to set
*/
public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation() {
System.out.println("Please come to my party");
}
}
import java.util.Scanner;
public class UseParty {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter number of guests for the party.>>");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println("The party has " + aParty.getGuests() + " guest");
aParty.displayInvitation();
}
}
public class DinnerParty extends Party {
private int dinnerChoice;
/**
2. * return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
}
import java.util.Scanner;
public class UseDinnerParty {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
int choice;
Scanner keyboard = new Scanner(System.in);
DinnerParty aDinnerParty = new DinnerParty();
System.out.print("Enter number of guests for the party.>>");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println("The party has " + aParty.getGuests() + " guest");
aParty.displayInvitation();
System.out.print("Enter number of guests for the dinner party>> ");
guests = keyboard.nextInt();
aDinnerParty.setGuests(guests);
System.out
.print("Enter the menu option-1 for children or 2 for beef >> ");
choice = keyboard.nextInt();
aDinnerParty.setDinnerChoice(choice);
System.out.println("The dinner party has " + aDinnerParty.getGuests());
System.out.println("menu option " + aDinnerParty.getDinnerChoice()
+ " will be served");
3. aDinnerParty.displayInvitation();
}
}
public class DinnerParty2 extends Party {
private int dinnerChoice;
/**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
public void displayInvitation() {
System.out.println("Please come to my dinner party");
}
}
import java.util.Scanner;
public class UseDinnerParty2 {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
int choice;
Scanner keyboard = new Scanner(System.in);
DinnerParty2 aDinnerParty = new DinnerParty2();
System.out.print("Enter number of guests for the party.>>");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println("The party has " + aParty.getGuests() + " guest");
aParty.displayInvitation();
System.out.print("Enter number of guests for the dinner party>> ");
4. guests = keyboard.nextInt();
aDinnerParty.setGuests(guests);
System.out
.print("Enter the menu option-1 for children or 2 for beef >> ");
choice = keyboard.nextInt();
aDinnerParty.setDinnerChoice(choice);
System.out.println("The dinner party has " + aDinnerParty.getGuests());
System.out.println("menu option " + aDinnerParty.getDinnerChoice()
+ " will be served");
aDinnerParty.displayInvitation();
}
}
public class PartyWithConstructor {
int guests;
public PartyWithConstructor() {
System.out.println("Creating a Party");
}
/**
* return the guests
*/
public int getGuests() {
return guests;
}
/**
* param guests the guests to set
*/
public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation() {
System.out.println("Please come to my party");
}
}
public class DinnerPartyWithConstructor extends PartyWithConstructor {
private int dinnerChoice;
5. /**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
public void displayInvitation() {
System.out.println("Please come to my dinner party");
}
}
public class useDinnerPartyWithConstructor {
public static void main(String[] arg) {
DinnerPartyWithConstructor aDinnerParty = new DinnerPartyWithConstructor();
}
}
public class PartyWithConstructor2 {
int guests;
public PartyWithConstructor2(int guests) {
this.guests=guests;
}
/**
* return the guests
*/
public int getGuests() {
return guests;
}
/**
* param guests the guests to set
*/
6. public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation() {
System.out.println("Please come to my party");
}
}
public class DinnerPartyWithConstructor2 extends PartyWithConstructor2 {
private int dinnerChoice;
public DinnerPartyWithConstructor2(int numGuests) {
super(numGuests);
}
/**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
public void displayInvitation() {
System.out.println("Please come to my dinner party");
}
}
Solution
public class Party {
private int guests;
/**
* return the guests
7. */
public int getGuests() {
return guests;
}
/**
* param guests
* the guests to set
*/
public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation() {
System.out.println("Please come to my party");
}
}
import java.util.Scanner;
public class UseParty {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter number of guests for the party.>>");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println("The party has " + aParty.getGuests() + " guest");
aParty.displayInvitation();
}
}
public class DinnerParty extends Party {
private int dinnerChoice;
/**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
8. /**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
}
import java.util.Scanner;
public class UseDinnerParty {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
int choice;
Scanner keyboard = new Scanner(System.in);
DinnerParty aDinnerParty = new DinnerParty();
System.out.print("Enter number of guests for the party.>>");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println("The party has " + aParty.getGuests() + " guest");
aParty.displayInvitation();
System.out.print("Enter number of guests for the dinner party>> ");
guests = keyboard.nextInt();
aDinnerParty.setGuests(guests);
System.out
.print("Enter the menu option-1 for children or 2 for beef >> ");
choice = keyboard.nextInt();
aDinnerParty.setDinnerChoice(choice);
System.out.println("The dinner party has " + aDinnerParty.getGuests());
System.out.println("menu option " + aDinnerParty.getDinnerChoice()
+ " will be served");
aDinnerParty.displayInvitation();
}
}
public class DinnerParty2 extends Party {
private int dinnerChoice;
9. /**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
public void displayInvitation() {
System.out.println("Please come to my dinner party");
}
}
import java.util.Scanner;
public class UseDinnerParty2 {
public static void main(String[] args) {
Party aParty = new Party();
int guests;
int choice;
Scanner keyboard = new Scanner(System.in);
DinnerParty2 aDinnerParty = new DinnerParty2();
System.out.print("Enter number of guests for the party.>>");
guests = keyboard.nextInt();
aParty.setGuests(guests);
System.out.println("The party has " + aParty.getGuests() + " guest");
aParty.displayInvitation();
System.out.print("Enter number of guests for the dinner party>> ");
guests = keyboard.nextInt();
aDinnerParty.setGuests(guests);
System.out
.print("Enter the menu option-1 for children or 2 for beef >> ");
choice = keyboard.nextInt();
10. aDinnerParty.setDinnerChoice(choice);
System.out.println("The dinner party has " + aDinnerParty.getGuests());
System.out.println("menu option " + aDinnerParty.getDinnerChoice()
+ " will be served");
aDinnerParty.displayInvitation();
}
}
public class PartyWithConstructor {
int guests;
public PartyWithConstructor() {
System.out.println("Creating a Party");
}
/**
* return the guests
*/
public int getGuests() {
return guests;
}
/**
* param guests the guests to set
*/
public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation() {
System.out.println("Please come to my party");
}
}
public class DinnerPartyWithConstructor extends PartyWithConstructor {
private int dinnerChoice;
/**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
11. }
/**
* param dinnerChoice the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
public void displayInvitation() {
System.out.println("Please come to my dinner party");
}
}
public class useDinnerPartyWithConstructor {
public static void main(String[] arg) {
DinnerPartyWithConstructor aDinnerParty = new DinnerPartyWithConstructor();
}
}
public class PartyWithConstructor2 {
int guests;
public PartyWithConstructor2(int guests) {
this.guests=guests;
}
/**
* return the guests
*/
public int getGuests() {
return guests;
}
/**
* param guests the guests to set
*/
public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation() {
System.out.println("Please come to my party");
12. }
}
public class DinnerPartyWithConstructor2 extends PartyWithConstructor2 {
private int dinnerChoice;
public DinnerPartyWithConstructor2(int numGuests) {
super(numGuests);
}
/**
* return the dinnerChoice
*/
public int getDinnerChoice() {
return dinnerChoice;
}
/**
* param dinnerChoice
* the dinnerChoice to set
*/
public void setDinnerChoice(int dinnerChoice) {
this.dinnerChoice = dinnerChoice;
}
public void displayInvitation() {
System.out.println("Please come to my dinner party");
}
}