You do not have permission to view the full content of this post.
Log in or register now.
Maraming salamat po!
Maraming salamat po!
How po imamark as solution?Pa mark as solution po
______________________________________________________________________
Party.java
public class Party
{
private int guests;
public int getGuests() {
return guests;
}
public void setGuests(int guests) {
this.guests = guests;
}
public void displayInvitation ()
{
System .out.println("Please come to my party ");
}
}
UseDinnerParty2.java
import java.util.*;
public class UseDinnerParty2
{
public static void main(String []arg)
{
int guests;
DinnerParty2 dinnerParty2 =new DinnerParty2();
Scanner keyboard= new Scanner (System.in);
System.out.print("Enter number of guests for the dinner party>> ");
guests =keyboard.nextInt();
dinnerParty2.setGuests(guests);
System.out.println("Enter the menu option-1 for children or 2 for beef >> ");
int choice=keyboard.nextInt();
dinnerParty2.setDinnerChoice(choice);
System.out.println("The dinner party has" + dinnerParty2.getGuests()+" guests ");
System.out.println("menu option "+dinnerParty2.getDinnerChoice()+" will be served");
dinnerParty2.displayInvitation();
}
}
DinnerParty2.java
public class DinnerParty2 extends Party{
private int dinnerChoice;
public int getDinnerChoice()
{
return dinnerChoice;
}
public void setDinnerChoice(int choice)
{
dinnerChoice=choice;
}
public void displayInvitation()
{
System.out.println("Please come to my dinner party! ");
}
}
Output:
Enter number of guests for the dinner party>> 50
Enter the menu option-1 for children or 2 for beef >>
1
The dinner party has50 guests
menu option 1 will be served
Please come to my dinner party!