SlideShare a Scribd company logo
1 of 12
Download to read offline
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 = 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;
/**
* 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
*/
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
*/
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 = 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;
/**
* 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
*/
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");
}
}

More Related Content

More from noelbuddy

11.B. Association of Southeast Asian NationsExplanationASEAN .pdf
11.B. Association of Southeast Asian NationsExplanationASEAN .pdf11.B. Association of Southeast Asian NationsExplanationASEAN .pdf
11.B. Association of Southeast Asian NationsExplanationASEAN .pdfnoelbuddy
 
1. Proteobacteria. It is the largest and metabolically diverse group.pdf
1. Proteobacteria. It is the largest and metabolically diverse group.pdf1. Proteobacteria. It is the largest and metabolically diverse group.pdf
1. Proteobacteria. It is the largest and metabolically diverse group.pdfnoelbuddy
 
1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdf
1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdf1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdf
1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdfnoelbuddy
 
1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdf
1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdf1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdf
1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdfnoelbuddy
 
just hit the ln button sorry guys .pdf
                     just hit the ln button sorry guys                .pdf                     just hit the ln button sorry guys                .pdf
just hit the ln button sorry guys .pdfnoelbuddy
 
I have seen in a table that pKa of H3PO4 =2.12 s.pdf
                     I have seen in a table that pKa of H3PO4 =2.12  s.pdf                     I have seen in a table that pKa of H3PO4 =2.12  s.pdf
I have seen in a table that pKa of H3PO4 =2.12 s.pdfnoelbuddy
 
#includeiostream#includestring#include fstreamusing name.pdf
#includeiostream#includestring#include fstreamusing name.pdf#includeiostream#includestring#include fstreamusing name.pdf
#includeiostream#includestring#include fstreamusing name.pdfnoelbuddy
 
Yes. You can prove it experimentally, but if you.pdf
                     Yes.  You can prove it experimentally, but if you.pdf                     Yes.  You can prove it experimentally, but if you.pdf
Yes. You can prove it experimentally, but if you.pdfnoelbuddy
 
the one which is oxidized is reducing agent Pb wa.pdf
                     the one which is oxidized is reducing agent Pb wa.pdf                     the one which is oxidized is reducing agent Pb wa.pdf
the one which is oxidized is reducing agent Pb wa.pdfnoelbuddy
 
   Internet the information super highway, open access, public user.pdf
   Internet the information super highway, open access, public user.pdf   Internet the information super highway, open access, public user.pdf
   Internet the information super highway, open access, public user.pdfnoelbuddy
 
What inequities exist in health careIf you take the question from.pdf
What inequities exist in health careIf you take the question from.pdfWhat inequities exist in health careIf you take the question from.pdf
What inequities exist in health careIf you take the question from.pdfnoelbuddy
 
The tops for collecting network based evidenceyou think that your.pdf
The tops for collecting network based evidenceyou think that your.pdfThe tops for collecting network based evidenceyou think that your.pdf
The tops for collecting network based evidenceyou think that your.pdfnoelbuddy
 
The main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdf
The main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdfThe main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdf
The main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdfnoelbuddy
 
The motor ANS is divided into the sympathetic nervous system, which .pdf
The motor ANS is divided into the sympathetic nervous system, which .pdfThe motor ANS is divided into the sympathetic nervous system, which .pdf
The motor ANS is divided into the sympathetic nervous system, which .pdfnoelbuddy
 
The formation of a disaccharide involves the condensation of two mon.pdf
The formation of a disaccharide involves the condensation of two mon.pdfThe formation of a disaccharide involves the condensation of two mon.pdf
The formation of a disaccharide involves the condensation of two mon.pdfnoelbuddy
 
Density = MassVolume = 4.023.57 = 1.126 gml .pdf
                     Density = MassVolume = 4.023.57 = 1.126 gml   .pdf                     Density = MassVolume = 4.023.57 = 1.126 gml   .pdf
Density = MassVolume = 4.023.57 = 1.126 gml .pdfnoelbuddy
 
D is correct. Solution D .pdf
                     D is correct. Solution                     D .pdf                     D is correct. Solution                     D .pdf
D is correct. Solution D .pdfnoelbuddy
 
doesnt work since S in SO3 is +6 oxidation stat.pdf
                     doesnt work since S in SO3 is +6 oxidation stat.pdf                     doesnt work since S in SO3 is +6 oxidation stat.pdf
doesnt work since S in SO3 is +6 oxidation stat.pdfnoelbuddy
 
tan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdf
tan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdftan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdf
tan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdfnoelbuddy
 
SolutionThe most abundant elements in the Earths crust are oxyg.pdf
SolutionThe most abundant elements in the Earths crust are oxyg.pdfSolutionThe most abundant elements in the Earths crust are oxyg.pdf
SolutionThe most abundant elements in the Earths crust are oxyg.pdfnoelbuddy
 

More from noelbuddy (20)

11.B. Association of Southeast Asian NationsExplanationASEAN .pdf
11.B. Association of Southeast Asian NationsExplanationASEAN .pdf11.B. Association of Southeast Asian NationsExplanationASEAN .pdf
11.B. Association of Southeast Asian NationsExplanationASEAN .pdf
 
1. Proteobacteria. It is the largest and metabolically diverse group.pdf
1. Proteobacteria. It is the largest and metabolically diverse group.pdf1. Proteobacteria. It is the largest and metabolically diverse group.pdf
1. Proteobacteria. It is the largest and metabolically diverse group.pdf
 
1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdf
1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdf1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdf
1. Adapt (adaptation)2. Evolve (evolution)3. Individual4. Non .pdf
 
1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdf
1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdf1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdf
1) WW1 - Great war or world war 1 is begin on 28th july 1914 in Eur.pdf
 
just hit the ln button sorry guys .pdf
                     just hit the ln button sorry guys                .pdf                     just hit the ln button sorry guys                .pdf
just hit the ln button sorry guys .pdf
 
I have seen in a table that pKa of H3PO4 =2.12 s.pdf
                     I have seen in a table that pKa of H3PO4 =2.12  s.pdf                     I have seen in a table that pKa of H3PO4 =2.12  s.pdf
I have seen in a table that pKa of H3PO4 =2.12 s.pdf
 
#includeiostream#includestring#include fstreamusing name.pdf
#includeiostream#includestring#include fstreamusing name.pdf#includeiostream#includestring#include fstreamusing name.pdf
#includeiostream#includestring#include fstreamusing name.pdf
 
Yes. You can prove it experimentally, but if you.pdf
                     Yes.  You can prove it experimentally, but if you.pdf                     Yes.  You can prove it experimentally, but if you.pdf
Yes. You can prove it experimentally, but if you.pdf
 
the one which is oxidized is reducing agent Pb wa.pdf
                     the one which is oxidized is reducing agent Pb wa.pdf                     the one which is oxidized is reducing agent Pb wa.pdf
the one which is oxidized is reducing agent Pb wa.pdf
 
   Internet the information super highway, open access, public user.pdf
   Internet the information super highway, open access, public user.pdf   Internet the information super highway, open access, public user.pdf
   Internet the information super highway, open access, public user.pdf
 
What inequities exist in health careIf you take the question from.pdf
What inequities exist in health careIf you take the question from.pdfWhat inequities exist in health careIf you take the question from.pdf
What inequities exist in health careIf you take the question from.pdf
 
The tops for collecting network based evidenceyou think that your.pdf
The tops for collecting network based evidenceyou think that your.pdfThe tops for collecting network based evidenceyou think that your.pdf
The tops for collecting network based evidenceyou think that your.pdf
 
The main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdf
The main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdfThe main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdf
The main culprit of the scene is suspect 2 ; Roger Coleman, the DNA .pdf
 
The motor ANS is divided into the sympathetic nervous system, which .pdf
The motor ANS is divided into the sympathetic nervous system, which .pdfThe motor ANS is divided into the sympathetic nervous system, which .pdf
The motor ANS is divided into the sympathetic nervous system, which .pdf
 
The formation of a disaccharide involves the condensation of two mon.pdf
The formation of a disaccharide involves the condensation of two mon.pdfThe formation of a disaccharide involves the condensation of two mon.pdf
The formation of a disaccharide involves the condensation of two mon.pdf
 
Density = MassVolume = 4.023.57 = 1.126 gml .pdf
                     Density = MassVolume = 4.023.57 = 1.126 gml   .pdf                     Density = MassVolume = 4.023.57 = 1.126 gml   .pdf
Density = MassVolume = 4.023.57 = 1.126 gml .pdf
 
D is correct. Solution D .pdf
                     D is correct. Solution                     D .pdf                     D is correct. Solution                     D .pdf
D is correct. Solution D .pdf
 
doesnt work since S in SO3 is +6 oxidation stat.pdf
                     doesnt work since S in SO3 is +6 oxidation stat.pdf                     doesnt work since S in SO3 is +6 oxidation stat.pdf
doesnt work since S in SO3 is +6 oxidation stat.pdf
 
tan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdf
tan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdftan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdf
tan(x) = 2 , 0x 90degcosx = 1sqrt5sinx =2sqrt5Usinf the tr.pdf
 
SolutionThe most abundant elements in the Earths crust are oxyg.pdf
SolutionThe most abundant elements in the Earths crust are oxyg.pdfSolutionThe most abundant elements in the Earths crust are oxyg.pdf
SolutionThe most abundant elements in the Earths crust are oxyg.pdf
 

Recently uploaded

OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 

Recently uploaded (20)

OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 

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"); } }