Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

=+ How well do you think you could do your job?

Answered: 1 week ago