- I just need levels 3-6 done. You don't need to do anything to the tester just add what the pdf says to the classes.
COW - Classes & Objects Level 1 Create a class called MyDate that has the following attributes: Variables: • int day – the day • int month – the month • int year – the year Methods: 1. MyDate (constructor) o Input Variables – int day, int month, int year o Output – none o Action – takes in and sets the initial variable values 2. getDay o Input Variables – none o Output – int day o Action – returns the day 3. getMonth o Input Variables – none o Output – int month o Action – returns the month 4. getYear o Input Variables – none o Output – int year o Action – returns the year 5. toString o Input Variables – none o Output – String description o Action – returns the date in the form “month \ day \ year”, ex: “1\13\1978” 6. equals o Input Variables – MyDate otherDate o Output – boolean same o Action – returns whether the date passed in is that same as this date 7. compareTo o Input Variables – MyDate otherDate o Output – int o Action – the value 0 is returned if the date passed is equal to this date; a value less than 0 if this date comes before the other date; and a value greater than 0 if this date comes after the other date. Level 2 Create a class called Name that has the following attributes: Variables: • String firstName – first name • String middleName – middle name • String lastName – last name Methods: 1. Name (constructor) o Input Variables – String firstName, String middleName, String lastName o Output – none o Action – takes in and sets the initial variable values 2. getFirstName o Input Variables – none o Output – String o Action – returns the first name 3. getMiddleName o Input Variables – none o Output – String o Action – returns the middle name 4. getLastName o Input Variables – none o Output – String o Action – returns the last name 5. toString o Input Variables – none o Output – String o Action – returns the first, middle, and last name together in one String with a space separating them 6. equals o Input Variables – Name otherName o Output – boolean same o Action – returns whether the name passed in is that same as this name (ie – all the names match up) 7. compareTo o Input Variables – Name otherName o Output – int o Action – the value 0 is returned if the name passed in equal to this name; a value less than 0 if this name is lexicographically less than the other name; and a value greater than 0 if this string is lexicographically greater than the other name. To compare names, first the last names are compared, then first, then middle. Level 3 Create a class called Address that has the following attributes: Variables: • int number – stores the number • String street – name of the street • boolean isApartment – whether or not it is an apartment • int apartmentNumber – the number of the apartment • String county – stores the county • String state – stores the state • int zipCode – stores the zip code as a 9 digit number • String country – stores the country Methods: 2. Address (constructor) o Input Variables – int number, String street, boolean isApartment, int apartmentNumber, String county, String state, int zipCode, String country o Output – none o Action – takes in and sets the initial variable values 3. Address (constructor) o Input Variables – int number, String street, String county, String state, int zipCode, String country o Output – none o Action – takes in and sets the initial variable values, this constructor also does not take in apartment information and so isApartment should be set to false and apartmentNumber should be set to 1 4. getNumber o Input Variables – none o Output – integer o Action – returns the number 5. getStreet o Input Variables – none o Output – String o Action – returns the street 6. isApartment o Input Variables – none o Output – boolean o Action – returns isApartment 7. getApartmentNumber o Input Variables – none o Output – int o Action – returns the apartment number 8. getCounty o Input Variables – none o Output – String o Action – returns the county 9. getState o Input Variables – none o Output – String o Action – returns the state 10. getZipCode o Input Variables – none o Output – int o Action – returns the zip code 11. getCountry o Input Variables – none o Output – String o Action – returns the country 12. toString o Input Variables – none o Output – String o Action – returns a String description of the address to appear in the following format: “1234 Milky Way Lane Sterling, VA 20165-6503 USA” “986 Glowood Drive, Apt 227 Pittsburgh, PA 15227-1214 USA” 13. equals o Input Variables – Address other o Output – boolean o Action – returns whether or not the address object passed in is the same Level 4 Create a class called Person that has the following attributes: Variables: • Name theName – stores the person’s name • MyDate birthday – stores the person’s birthday • Address home – stores the person’s home address • int socialSecurityNumber – stores the person’s social security number • String [] interests – an array that stores the interests of the person, the array can be any size Methods: 1. Person (constructor) o Input Variables – Name theName, MyDate birthday, Address home, int socialSecurityNumber, String [] interests o Output – none o Action – takes in and sets the initial variable values 2. getName o Input Variables – none o Output – Name o Action – returns the name 3. getBirthDay o Input Variables – none o Output – MyDate o Action – returns the birthday 4. getHomeAddress o Input Variables – none o Output – Address o Action – returns the homeAddress 5. getSocSecNumber o Input Variables – none o Output – int o Action – returns the socialSecurityNumber 6. getInterests o Input Variables – none o Output – String [] o Action – returns the interests 7. toString o Input Variables – none o Output – String o Action – returns a String description of the person that includes all information about them 8. equals o Input Variables – Person other o Output – boolean o Action –returns whether or not the person passed in is the same by comparing social security numbers 9. compareTo o Input Variables – Person other o Output – integer o Action – Compares this person with person passed in by using their names. Level 5 Create a class called Group that has the following attributes: Variables: • Person [] people – stores an array of people Methods: 1. Group (constructor) o Input Variables – Person [] people o Output – none o Action – takes in and sets the initial variable values 2. getPeople o Input Variables – none o Output – Person [] o Action – returns the array of people in the group 3. printList o Input Variables – none o Output – none o Action – prints out the names of everyone in the group 4. printAllWithSurname o Input Variables – String lastName o Output – none o Action – prints out the name of everyone with the specified last name. 5. printThoseOnStreet o Input Variables – String streetName o Output – none o Action – prints out everyone who lives on the specified Street 6. toString o Input Variables – none o Output – String o Action – returns a String that contains the names of everyone in the group 7. equals o Input Variables – Group other o Output – boolean o Action – returns whether or not the same people are in each group. You may assume that the people are in alphabetical order 8. compareTo o Input Variables – Group other o Output – integer o Action – Compares this group with the other group passed in based on size. If both groups have the same number of people, then a zero is returned. If this group has more people, then a positive number is returned. If the other group has more people, then a negative number is returned. Level 6 Add the following methods to the MyDate class: Methods: 1. yearsFrom o Input Variables – MyDate other o Output – int o Action – returns the number of years between the two dates. If the number of years is 4.5 then just a 4 is returned. It is not given whether the Date passed in comes before or after the Date object that it was passed into. Add the following methods to the Group class: Methods: 2. isInGroup o Input Variables – Person them o Output – boolean o Action – returns whether or not the person is in the group 3. printThoseBornInMonthOf o Input Variables – String birthMonth o Output – none o Action – prints out the name of everyone born in the specified month. Keep in mind that month is stored as an int in Date and a String description is passed in 4. printThoseWithAnInterestIn o Input Variables – String interest o Output – none o Action – prints out the name of everyone who has the interest passed in 5. printInZipCode o Input Variables – 5 digit zip code o Output – none o Action – prints out the name of everyone who lives in the given 5 digit zip code 6. printAllOlderThan o Input Variables – int numYears, MyDate currentDate o Output