Question: You are given three incomplete classes 1. Date class 2. Person class (has an object of Date class as an attribute) 3. Census class (has

You are given three incomplete classes

1. Date class

2. Person class (has an object of Date class as an attribute)

3. Census class (has an array of Person objects as an attribute)

Your tasks are the following:

1. Date Class

- complete the constructor method

- complete the isYounger method

2. Person Class

- complete copy constructor method

- complete the isYounger method

3. Census class

- Complete constructor

- Complete isYounger method

The description of isYounger method is given within the class code.

You don't need to test these classes in the main.

Feel free to add additional methods in the classes if necessary.

package quiz2;

class Census { private Person[] citizens;

//complete a constructor public Census(Person[] p) {

}

//returns the a copy of the youngest person in the Person[] citizens array. //assume that no two person have the same birth date. public Person getYoungest() { Person youngest = null; //insert code here

return youngest; } } class Date { private int day; private int month; private int year; public Date(int d, int m, int y) { day = d; month = m; year = y; } //copy constructor public Date(Date aDate) { day = aDate.day; month = aDate.month; year = aDate.year; }

//complete isYounger method here // returns true if the calling object is younger than aDate object // otherwise returns false public boolean Date(Date aDate) { boolean yes = true; //insert code here

return yes;

} } class Person { private String name; private Date Birth;

//the constructor method public Person(String aName, Date aBirth) { name = aName; Birth = new Date(aBirth); } //complete copy constructor public Person(Person aPerson) { name = aPerson.name; Birth = new Date(aPerson.Birth); } //complete the isYouunger method //returns true if the calling Person object is younger than the aPerson object //otherwise returns false public boolean isYounger(Person aPerson) { boolean younger = true; //insert code here

return younger; } } public class Quiz2 {

/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!