Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3) Part 1) Give a complete definition of a class called Person that has two priv

ID: 3704543 • Letter: 3

Question

3) Part 1) Give a complete definition of a class called Person that has two private instance variables. One for the person's name the other for the person's age. Include accessor methods and mutator methods for each instance variable. Also include a method that sets both the name and age of a person Part 2) Add methods to the person class to perform the following tasks Test whether two person objects are equal Test whether two person objects have the same name Test whether two person objects are the same age Test whether one person objects is older than another Test whether one person object is younger than another Write a Driver (test) program that demonstrates each method with at least one true and false case for each of the method tests

Explanation / Answer

public String getFirstName()
{
return firstName;
}
public String getMiddlesNames()
{
return middleNames;
}
public String getLastName()
{
return lastName;
}

These strategies continually come back constant information kind as their corresponding non-public field e.g., String and so merely come back the worth of that personal field.

We can currently access their values through the strategies of someone object:
public class PersonExample {

public static void main(String[] args) {

Person dave = new Person("Dave", "Bob Bill", "Davidson", "12 Pall Mall");
System.out.println(dave.getFirstName() + " " + dave.getMiddlesNames() + " " + dave.getLastName());
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote