SlideShare a Scribd company logo
1 of 8
Download to read offline
So Far I have these two classes but I need help with my persontest class:
The next step is to add method calls for the accessor methods after each input:
//Reading and updating values
System.out.print(" Enter Person Name: ");
person1.setPersonName(sc.nextLine());
System.out.println("You entered: " + person1.getPersonName());
Call the accessor function each time you ask for input, after capturing that input. Then repeat for
a second Person, only this time call the constructor that takes the student id as a parameter.
7 import java.util.Scanner;
8
9 class PersonTest
10 {
11 //Main method
12 public static void main(String args[])
13 {
14 Scanner sc = new Scanner(System.in);
15
16 //Creating object
17 Persons_Information person1 = new Persons_Information();
18
19 //Reading and updating values
20 System.out.print(" Enter Person Name: ");
21 person1.setPersonName(sc.nextLine());
22
23 System.out.print(" Enter Current Address: ");
24 person1.setCurrentAdress(sc.nextLine());
25
26 System.out.print(" Enter Permanent Address: ");
27 person1.setpermanentAdress(sc.nextLine());
28
29 System.out.print(" Enter ID number: ");
30 person1.setIdNumber(sc.nextInt());
31
32 sc.nextLine();
33
34 System.out.print(" Enter Birth Date: ");
35 person1.setBirthDate(sc.nextLine());
36
37
38 System.out.print(" Enter Person Age: ");
39 person1.setPersonAge(sc.nextInt());
40
41
42 System.out.print(" Enter Entry Year: ");
43 person1.setEntryYear(sc.nextInt());
44
45
46 System.out.print(" Enter Total Years: ");
47 person1.setTotalYears(sc.nextInt());
48
49 //Printing person 1 details
50 System.out.println(" Person 1:  " + person1.toString());
51 }
52 }
Solution
Persons_Information.java
public class Persons_Information {
//Declaring instance variables
private String personName;
private String currentAdress;
private String permanentAdress;
private int idNumber;
private String birthDate;
private int personAge;
private int entryYear;
private int totalYears;
//Zero argumented constructor
public Persons_Information()
{
}
//Parameterized constructor
public Persons_Information(int idNumber) {
this.idNumber = idNumber;
}
//Getters and setters
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public String getCurrentAdress() {
return currentAdress;
}
public void setCurrentAdress(String currentAdress) {
this.currentAdress = currentAdress;
}
public String getPermanentAdress() {
return permanentAdress;
}
public void setPermanentAdress(String permanentAdress) {
this.permanentAdress = permanentAdress;
}
public int getIdNumber() {
return idNumber;
}
public void setIdNumber(int idNumber) {
this.idNumber = idNumber;
}
public String getBirthDate() {
return birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public int getPersonAge() {
return personAge;
}
public void setPersonAge(int personAge) {
this.personAge = personAge;
}
public int getEntryYear() {
return entryYear;
}
public void setEntryYear(int entryYear) {
this.entryYear = entryYear;
}
public int getTotalYears() {
return totalYears;
}
public void setTotalYears(int totalYears) {
this.totalYears = totalYears;
}
//toString() method is used to display the contents of an object indide it
@Override
public String toString() {
return "Persons_Information# Person Name=" + personName + " Current Adress="
+ currentAdress + " Permanent Adress=" + permanentAdress
+ " Id Number=" + idNumber + " Birth Date=" + birthDate
+ " Person Age=" + personAge + " EntryYear=" + entryYear
+ " TotalYears=" + totalYears;
}
}
___________________________________
PersonTest.java
import java.util.Scanner;
class PersonTest
{
//Main method
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
//Creating object
Persons_Information person1 = new Persons_Information();
//Reading and updating values
System.out.print(" Enter Person Name: ");
person1.setPersonName(sc.nextLine());
System.out.println("You entered: " + person1.getPersonName());
System.out.print(" Enter Current Address: ");
person1.setCurrentAdress(sc.nextLine());
System.out.println("You entered: " + person1.getCurrentAdress());
System.out.print(" Enter Permanent Address: ");
person1.setPermanentAdress(sc.nextLine());
System.out.println("You entered: " + person1.getPermanentAdress());
System.out.print(" Enter ID number: ");
person1.setIdNumber(sc.nextInt());
System.out.println("You entered: " + person1.getIdNumber());
sc.nextLine();
System.out.print(" Enter Birth Date: ");
person1.setBirthDate(sc.nextLine());
System.out.println("You entered: " + person1.getBirthDate());
System.out.print(" Enter Person Age: ");
person1.setPersonAge(sc.nextInt());
System.out.println("You entered: " + person1.getPersonAge());
System.out.print(" Enter Entry Year: ");
person1.setEntryYear(sc.nextInt());
System.out.println("You entered: " + person1.getEntryYear());
System.out.print(" Enter Total Years: ");
person1.setTotalYears(sc.nextInt());
System.out.println("You entered: " + person1.getTotalYears());
//Printing person 1 details
System.out.println(" Person 1:  " + person1.toString());
System.out.println("______Creating the Person#2 Object______");
System.out.print(" Enter ID number: ");
int id=sc.nextInt();
Persons_Information pi2=new Persons_Information(id);
System.out.println("You Entered Person Id :"+pi2.getIdNumber());
sc.nextLine();
//Reading and updating values
System.out.print(" Enter Person Name: ");
pi2.setPersonName(sc.nextLine());
System.out.println("You entered: " + pi2.getPersonName());
System.out.print(" Enter Current Address: ");
pi2.setCurrentAdress(sc.nextLine());
System.out.println("You entered: " + pi2.getCurrentAdress());
System.out.print(" Enter Permanent Address: ");
pi2.setPermanentAdress(sc.nextLine());
System.out.println("You entered: " + pi2.getPermanentAdress());
System.out.print(" Enter Birth Date: ");
pi2.setBirthDate(sc.nextLine());
System.out.println("You entered: " + pi2.getBirthDate());
System.out.print(" Enter Person Age: ");
pi2.setPersonAge(sc.nextInt());
System.out.println("You entered: " + pi2.getPersonAge());
System.out.print(" Enter Entry Year: ");
pi2.setEntryYear(sc.nextInt());
System.out.println("You entered: " + pi2.getEntryYear());
System.out.print(" Enter Total Years: ");
pi2.setTotalYears(sc.nextInt());
System.out.println("You entered: " + pi2.getTotalYears());
//Printing person 2 details
System.out.println(" Person 1:  " + pi2.toString());
}
}
____________________________
output:
Enter Person Name: Williams
You entered: Williams
Enter Current Address: 101,Park Street, Newyork
You entered: 101,Park Street, Newyork
Enter Permanent Address: 101,Park Street, Newyork
You entered: 101,Park Street, Newyork
Enter ID number: 1234
You entered: 1234
Enter Birth Date: oct-12-2000
You entered: oct-12-2000
Enter Person Age: 16
You entered: 16
Enter Entry Year: 2016
You entered: 2016
Enter Total Years: 5
You entered: 5
Person 1:
Persons_Information#
Person Name=Williams
Current Adress=101,Park Street, Newyork
Permanent Adress=101,Park Street, Newyork
Id Number=1234
Birth Date=oct-12-2000
Person Age=16
EntryYear=2016
TotalYears=5
______Creating the Person#2 Object______
Enter ID number: 7891
You Entered Person Id :7891
Enter Person Name: Kane
You entered: Kane
Enter Current Address: 22,Church Road,Newyork
You entered: 22,Church Road,Newyork
Enter Permanent Address: 22,Church Road,Newyork
You entered: 22,Church Road,Newyork
Enter Birth Date: nov-12-2001
You entered: nov-12-2001
Enter Person Age: 15
You entered: 15
Enter Entry Year: 2010
You entered: 2010
Enter Total Years: 5
You entered: 5
Person 1:
Persons_Information#
Person Name=Kane
Current Adress=22,Church Road,Newyork
Permanent Adress=22,Church Road,Newyork
Id Number=7891
Birth Date=nov-12-2001
Person Age=15
EntryYear=2010
TotalYears=5
___________________Thank You

More Related Content

Similar to So Far I have these two classes but I need help with my persontest c.pdf

Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfkostikjaylonshaewe47
 
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdfallwayscollection
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfallystraders
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...Nithin Kumar,VVCE, Mysuru
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfankitmobileshop235
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfAnkitchhabra28
 
import java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfimport java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfaquazac
 
Need help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdfNeed help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdfarihanthtoysandgifts
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfakshpatil4
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfarihantmum
 
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfNot sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfwasemanivytreenrco51
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdffeelingspaldi
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docxajoy21
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
i need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfi need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfirshadoptical
 
There is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdfThere is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdfaashienterprisesuk
 
Modify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdfModify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdffcaindore
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfarrowmobile
 

Similar to So Far I have these two classes but I need help with my persontest c.pdf (20)

Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
 
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdf
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
 
Manual tecnic sergi_subirats
Manual tecnic sergi_subiratsManual tecnic sergi_subirats
Manual tecnic sergi_subirats
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 
import java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfimport java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdf
 
Need help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdfNeed help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdf
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdf
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
 
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfNot sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdf
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docx
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
i need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfi need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdf
 
There is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdfThere is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdf
 
Modify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdfModify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdf
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
 

More from arihantgiftgallery

In Drosophila, gray body color is dominant to ebony body color, while.pdf
In Drosophila, gray body color is dominant to ebony body color, while.pdfIn Drosophila, gray body color is dominant to ebony body color, while.pdf
In Drosophila, gray body color is dominant to ebony body color, while.pdfarihantgiftgallery
 
I need help with this maze gui that I wrote in java, I am trying to .pdf
I need help with this maze gui that I wrote in java, I am trying to .pdfI need help with this maze gui that I wrote in java, I am trying to .pdf
I need help with this maze gui that I wrote in java, I am trying to .pdfarihantgiftgallery
 
G and g are dominant and recessive alleles, respectively, for a gene.pdf
G and g are dominant and recessive alleles, respectively, for a gene.pdfG and g are dominant and recessive alleles, respectively, for a gene.pdf
G and g are dominant and recessive alleles, respectively, for a gene.pdfarihantgiftgallery
 
Explain how particles of different sizes are cleared from different a.pdf
Explain how particles of different sizes are cleared from different a.pdfExplain how particles of different sizes are cleared from different a.pdf
Explain how particles of different sizes are cleared from different a.pdfarihantgiftgallery
 
Egineering Ethics Planned obsolescence is the practice of producing.pdf
Egineering Ethics Planned obsolescence is the practice of producing.pdfEgineering Ethics Planned obsolescence is the practice of producing.pdf
Egineering Ethics Planned obsolescence is the practice of producing.pdfarihantgiftgallery
 
Endospores do not stain easily Perhaps you have seen them as unstain.pdf
Endospores do not stain easily Perhaps you have seen them as unstain.pdfEndospores do not stain easily Perhaps you have seen them as unstain.pdf
Endospores do not stain easily Perhaps you have seen them as unstain.pdfarihantgiftgallery
 
Describe how the concepts of leadership and management differ from e.pdf
Describe how the concepts of leadership and management differ from e.pdfDescribe how the concepts of leadership and management differ from e.pdf
Describe how the concepts of leadership and management differ from e.pdfarihantgiftgallery
 
Contemporary historyFor each year since 1945, select an event that.pdf
Contemporary historyFor each year since 1945, select an event that.pdfContemporary historyFor each year since 1945, select an event that.pdf
Contemporary historyFor each year since 1945, select an event that.pdfarihantgiftgallery
 
A variety of media and culture conditions can be used to culture and .pdf
A variety of media and culture conditions can be used to culture and .pdfA variety of media and culture conditions can be used to culture and .pdf
A variety of media and culture conditions can be used to culture and .pdfarihantgiftgallery
 
A program consists of 4 musical numbers and 3 speeches. In how many .pdf
A program consists of 4 musical numbers and 3 speeches. In how many .pdfA program consists of 4 musical numbers and 3 speeches. In how many .pdf
A program consists of 4 musical numbers and 3 speeches. In how many .pdfarihantgiftgallery
 
A Moving to another question will save this response. Question 4 Iden.pdf
A Moving to another question will save this response. Question 4 Iden.pdfA Moving to another question will save this response. Question 4 Iden.pdf
A Moving to another question will save this response. Question 4 Iden.pdfarihantgiftgallery
 
A plant with a very extensive root system would be able to better abs.pdf
A plant with a very extensive root system would be able to better abs.pdfA plant with a very extensive root system would be able to better abs.pdf
A plant with a very extensive root system would be able to better abs.pdfarihantgiftgallery
 
property, plant, and equipment are categorized as property, pla.pdf
property, plant, and equipment are categorized as property, pla.pdfproperty, plant, and equipment are categorized as property, pla.pdf
property, plant, and equipment are categorized as property, pla.pdfarihantgiftgallery
 
Write a program in Matlab using Newtons method to solve this syste.pdf
Write a program in Matlab using Newtons method to solve this syste.pdfWrite a program in Matlab using Newtons method to solve this syste.pdf
Write a program in Matlab using Newtons method to solve this syste.pdfarihantgiftgallery
 
Why is it that bacterial ribosomes can begin translation before mRNA.pdf
Why is it that bacterial ribosomes can begin translation before mRNA.pdfWhy is it that bacterial ribosomes can begin translation before mRNA.pdf
Why is it that bacterial ribosomes can begin translation before mRNA.pdfarihantgiftgallery
 
Write a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdfWrite a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdfarihantgiftgallery
 
Which standards organization defined the Ethernet standardA.IEEE.pdf
Which standards organization defined the Ethernet standardA.IEEE.pdfWhich standards organization defined the Ethernet standardA.IEEE.pdf
Which standards organization defined the Ethernet standardA.IEEE.pdfarihantgiftgallery
 
When the pH of a solution changes from 2 to 6 a) That solution beco.pdf
When the pH of a solution changes from 2 to 6 a) That solution beco.pdfWhen the pH of a solution changes from 2 to 6 a) That solution beco.pdf
When the pH of a solution changes from 2 to 6 a) That solution beco.pdfarihantgiftgallery
 
Which is the correct answer Consider the characteristics of moss an.pdf
Which is the correct answer Consider the characteristics of moss an.pdfWhich is the correct answer Consider the characteristics of moss an.pdf
Which is the correct answer Consider the characteristics of moss an.pdfarihantgiftgallery
 
Unequal crossing over is responsible for creating paracentric inversi.pdf
Unequal crossing over is responsible for creating paracentric inversi.pdfUnequal crossing over is responsible for creating paracentric inversi.pdf
Unequal crossing over is responsible for creating paracentric inversi.pdfarihantgiftgallery
 

More from arihantgiftgallery (20)

In Drosophila, gray body color is dominant to ebony body color, while.pdf
In Drosophila, gray body color is dominant to ebony body color, while.pdfIn Drosophila, gray body color is dominant to ebony body color, while.pdf
In Drosophila, gray body color is dominant to ebony body color, while.pdf
 
I need help with this maze gui that I wrote in java, I am trying to .pdf
I need help with this maze gui that I wrote in java, I am trying to .pdfI need help with this maze gui that I wrote in java, I am trying to .pdf
I need help with this maze gui that I wrote in java, I am trying to .pdf
 
G and g are dominant and recessive alleles, respectively, for a gene.pdf
G and g are dominant and recessive alleles, respectively, for a gene.pdfG and g are dominant and recessive alleles, respectively, for a gene.pdf
G and g are dominant and recessive alleles, respectively, for a gene.pdf
 
Explain how particles of different sizes are cleared from different a.pdf
Explain how particles of different sizes are cleared from different a.pdfExplain how particles of different sizes are cleared from different a.pdf
Explain how particles of different sizes are cleared from different a.pdf
 
Egineering Ethics Planned obsolescence is the practice of producing.pdf
Egineering Ethics Planned obsolescence is the practice of producing.pdfEgineering Ethics Planned obsolescence is the practice of producing.pdf
Egineering Ethics Planned obsolescence is the practice of producing.pdf
 
Endospores do not stain easily Perhaps you have seen them as unstain.pdf
Endospores do not stain easily Perhaps you have seen them as unstain.pdfEndospores do not stain easily Perhaps you have seen them as unstain.pdf
Endospores do not stain easily Perhaps you have seen them as unstain.pdf
 
Describe how the concepts of leadership and management differ from e.pdf
Describe how the concepts of leadership and management differ from e.pdfDescribe how the concepts of leadership and management differ from e.pdf
Describe how the concepts of leadership and management differ from e.pdf
 
Contemporary historyFor each year since 1945, select an event that.pdf
Contemporary historyFor each year since 1945, select an event that.pdfContemporary historyFor each year since 1945, select an event that.pdf
Contemporary historyFor each year since 1945, select an event that.pdf
 
A variety of media and culture conditions can be used to culture and .pdf
A variety of media and culture conditions can be used to culture and .pdfA variety of media and culture conditions can be used to culture and .pdf
A variety of media and culture conditions can be used to culture and .pdf
 
A program consists of 4 musical numbers and 3 speeches. In how many .pdf
A program consists of 4 musical numbers and 3 speeches. In how many .pdfA program consists of 4 musical numbers and 3 speeches. In how many .pdf
A program consists of 4 musical numbers and 3 speeches. In how many .pdf
 
A Moving to another question will save this response. Question 4 Iden.pdf
A Moving to another question will save this response. Question 4 Iden.pdfA Moving to another question will save this response. Question 4 Iden.pdf
A Moving to another question will save this response. Question 4 Iden.pdf
 
A plant with a very extensive root system would be able to better abs.pdf
A plant with a very extensive root system would be able to better abs.pdfA plant with a very extensive root system would be able to better abs.pdf
A plant with a very extensive root system would be able to better abs.pdf
 
property, plant, and equipment are categorized as property, pla.pdf
property, plant, and equipment are categorized as property, pla.pdfproperty, plant, and equipment are categorized as property, pla.pdf
property, plant, and equipment are categorized as property, pla.pdf
 
Write a program in Matlab using Newtons method to solve this syste.pdf
Write a program in Matlab using Newtons method to solve this syste.pdfWrite a program in Matlab using Newtons method to solve this syste.pdf
Write a program in Matlab using Newtons method to solve this syste.pdf
 
Why is it that bacterial ribosomes can begin translation before mRNA.pdf
Why is it that bacterial ribosomes can begin translation before mRNA.pdfWhy is it that bacterial ribosomes can begin translation before mRNA.pdf
Why is it that bacterial ribosomes can begin translation before mRNA.pdf
 
Write a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdfWrite a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdf
 
Which standards organization defined the Ethernet standardA.IEEE.pdf
Which standards organization defined the Ethernet standardA.IEEE.pdfWhich standards organization defined the Ethernet standardA.IEEE.pdf
Which standards organization defined the Ethernet standardA.IEEE.pdf
 
When the pH of a solution changes from 2 to 6 a) That solution beco.pdf
When the pH of a solution changes from 2 to 6 a) That solution beco.pdfWhen the pH of a solution changes from 2 to 6 a) That solution beco.pdf
When the pH of a solution changes from 2 to 6 a) That solution beco.pdf
 
Which is the correct answer Consider the characteristics of moss an.pdf
Which is the correct answer Consider the characteristics of moss an.pdfWhich is the correct answer Consider the characteristics of moss an.pdf
Which is the correct answer Consider the characteristics of moss an.pdf
 
Unequal crossing over is responsible for creating paracentric inversi.pdf
Unequal crossing over is responsible for creating paracentric inversi.pdfUnequal crossing over is responsible for creating paracentric inversi.pdf
Unequal crossing over is responsible for creating paracentric inversi.pdf
 

Recently uploaded

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Recently uploaded (20)

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

So Far I have these two classes but I need help with my persontest c.pdf

  • 1. So Far I have these two classes but I need help with my persontest class: The next step is to add method calls for the accessor methods after each input: //Reading and updating values System.out.print(" Enter Person Name: "); person1.setPersonName(sc.nextLine()); System.out.println("You entered: " + person1.getPersonName()); Call the accessor function each time you ask for input, after capturing that input. Then repeat for a second Person, only this time call the constructor that takes the student id as a parameter. 7 import java.util.Scanner; 8 9 class PersonTest 10 { 11 //Main method 12 public static void main(String args[]) 13 { 14 Scanner sc = new Scanner(System.in); 15 16 //Creating object 17 Persons_Information person1 = new Persons_Information(); 18 19 //Reading and updating values 20 System.out.print(" Enter Person Name: "); 21 person1.setPersonName(sc.nextLine()); 22 23 System.out.print(" Enter Current Address: "); 24 person1.setCurrentAdress(sc.nextLine()); 25 26 System.out.print(" Enter Permanent Address: "); 27 person1.setpermanentAdress(sc.nextLine()); 28 29 System.out.print(" Enter ID number: "); 30 person1.setIdNumber(sc.nextInt()); 31 32 sc.nextLine(); 33
  • 2. 34 System.out.print(" Enter Birth Date: "); 35 person1.setBirthDate(sc.nextLine()); 36 37 38 System.out.print(" Enter Person Age: "); 39 person1.setPersonAge(sc.nextInt()); 40 41 42 System.out.print(" Enter Entry Year: "); 43 person1.setEntryYear(sc.nextInt()); 44 45 46 System.out.print(" Enter Total Years: "); 47 person1.setTotalYears(sc.nextInt()); 48 49 //Printing person 1 details 50 System.out.println(" Person 1: " + person1.toString()); 51 } 52 } Solution Persons_Information.java public class Persons_Information { //Declaring instance variables private String personName; private String currentAdress; private String permanentAdress; private int idNumber; private String birthDate; private int personAge; private int entryYear; private int totalYears; //Zero argumented constructor public Persons_Information()
  • 3. { } //Parameterized constructor public Persons_Information(int idNumber) { this.idNumber = idNumber; } //Getters and setters public String getPersonName() { return personName; } public void setPersonName(String personName) { this.personName = personName; } public String getCurrentAdress() { return currentAdress; } public void setCurrentAdress(String currentAdress) { this.currentAdress = currentAdress; } public String getPermanentAdress() { return permanentAdress; } public void setPermanentAdress(String permanentAdress) { this.permanentAdress = permanentAdress; } public int getIdNumber() { return idNumber; } public void setIdNumber(int idNumber) { this.idNumber = idNumber; } public String getBirthDate() { return birthDate; } public void setBirthDate(String birthDate) { this.birthDate = birthDate;
  • 4. } public int getPersonAge() { return personAge; } public void setPersonAge(int personAge) { this.personAge = personAge; } public int getEntryYear() { return entryYear; } public void setEntryYear(int entryYear) { this.entryYear = entryYear; } public int getTotalYears() { return totalYears; } public void setTotalYears(int totalYears) { this.totalYears = totalYears; } //toString() method is used to display the contents of an object indide it @Override public String toString() { return "Persons_Information# Person Name=" + personName + " Current Adress=" + currentAdress + " Permanent Adress=" + permanentAdress + " Id Number=" + idNumber + " Birth Date=" + birthDate + " Person Age=" + personAge + " EntryYear=" + entryYear + " TotalYears=" + totalYears; } } ___________________________________ PersonTest.java import java.util.Scanner; class PersonTest { //Main method public static void main(String args[])
  • 5. { Scanner sc = new Scanner(System.in); //Creating object Persons_Information person1 = new Persons_Information(); //Reading and updating values System.out.print(" Enter Person Name: "); person1.setPersonName(sc.nextLine()); System.out.println("You entered: " + person1.getPersonName()); System.out.print(" Enter Current Address: "); person1.setCurrentAdress(sc.nextLine()); System.out.println("You entered: " + person1.getCurrentAdress()); System.out.print(" Enter Permanent Address: "); person1.setPermanentAdress(sc.nextLine()); System.out.println("You entered: " + person1.getPermanentAdress()); System.out.print(" Enter ID number: "); person1.setIdNumber(sc.nextInt()); System.out.println("You entered: " + person1.getIdNumber()); sc.nextLine(); System.out.print(" Enter Birth Date: "); person1.setBirthDate(sc.nextLine()); System.out.println("You entered: " + person1.getBirthDate()); System.out.print(" Enter Person Age: "); person1.setPersonAge(sc.nextInt()); System.out.println("You entered: " + person1.getPersonAge()); System.out.print(" Enter Entry Year: "); person1.setEntryYear(sc.nextInt()); System.out.println("You entered: " + person1.getEntryYear());
  • 6. System.out.print(" Enter Total Years: "); person1.setTotalYears(sc.nextInt()); System.out.println("You entered: " + person1.getTotalYears()); //Printing person 1 details System.out.println(" Person 1: " + person1.toString()); System.out.println("______Creating the Person#2 Object______"); System.out.print(" Enter ID number: "); int id=sc.nextInt(); Persons_Information pi2=new Persons_Information(id); System.out.println("You Entered Person Id :"+pi2.getIdNumber()); sc.nextLine(); //Reading and updating values System.out.print(" Enter Person Name: "); pi2.setPersonName(sc.nextLine()); System.out.println("You entered: " + pi2.getPersonName()); System.out.print(" Enter Current Address: "); pi2.setCurrentAdress(sc.nextLine()); System.out.println("You entered: " + pi2.getCurrentAdress()); System.out.print(" Enter Permanent Address: "); pi2.setPermanentAdress(sc.nextLine()); System.out.println("You entered: " + pi2.getPermanentAdress()); System.out.print(" Enter Birth Date: "); pi2.setBirthDate(sc.nextLine()); System.out.println("You entered: " + pi2.getBirthDate()); System.out.print(" Enter Person Age: "); pi2.setPersonAge(sc.nextInt());
  • 7. System.out.println("You entered: " + pi2.getPersonAge()); System.out.print(" Enter Entry Year: "); pi2.setEntryYear(sc.nextInt()); System.out.println("You entered: " + pi2.getEntryYear()); System.out.print(" Enter Total Years: "); pi2.setTotalYears(sc.nextInt()); System.out.println("You entered: " + pi2.getTotalYears()); //Printing person 2 details System.out.println(" Person 1: " + pi2.toString()); } } ____________________________ output: Enter Person Name: Williams You entered: Williams Enter Current Address: 101,Park Street, Newyork You entered: 101,Park Street, Newyork Enter Permanent Address: 101,Park Street, Newyork You entered: 101,Park Street, Newyork Enter ID number: 1234 You entered: 1234 Enter Birth Date: oct-12-2000 You entered: oct-12-2000 Enter Person Age: 16 You entered: 16 Enter Entry Year: 2016 You entered: 2016 Enter Total Years: 5 You entered: 5 Person 1: Persons_Information# Person Name=Williams
  • 8. Current Adress=101,Park Street, Newyork Permanent Adress=101,Park Street, Newyork Id Number=1234 Birth Date=oct-12-2000 Person Age=16 EntryYear=2016 TotalYears=5 ______Creating the Person#2 Object______ Enter ID number: 7891 You Entered Person Id :7891 Enter Person Name: Kane You entered: Kane Enter Current Address: 22,Church Road,Newyork You entered: 22,Church Road,Newyork Enter Permanent Address: 22,Church Road,Newyork You entered: 22,Church Road,Newyork Enter Birth Date: nov-12-2001 You entered: nov-12-2001 Enter Person Age: 15 You entered: 15 Enter Entry Year: 2010 You entered: 2010 Enter Total Years: 5 You entered: 5 Person 1: Persons_Information# Person Name=Kane Current Adress=22,Church Road,Newyork Permanent Adress=22,Church Road,Newyork Id Number=7891 Birth Date=nov-12-2001 Person Age=15 EntryYear=2010 TotalYears=5 ___________________Thank You