Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this project, you are provided with 4 classes: Person PartTime Pets Driver PartTime employee IS-A person and PartTime employee HAS-A pet. Modify/implement the following

For this project, you are provided with 4 classes:

Person

PartTime

Pets

Driver

PartTime employee IS-A person and PartTime employee HAS-A pet.

Modify/implement the following features

Add the class bird, birds are considered pets. Collect feathers color and length of the beak as states for this class.

Add the classes graduate and under graduate students. Graduate and under-graduate students are considered part-time employees. Collect GPA and classification (Freshman, sophomore junior and senior) as states for the under-graduate student. Collect student degree (BS or AS) and monthly salary as state for the graduate student.

Each class must have all the standard methods: getters; setters; constructors (including the copy); makeCopy; toString.

Test your application with following scenarios:

1. Create the object Mary Anderson with social security number 342-45-9812 who is an undergraduate student with GPA equal to 3.5. Mary is a junior student with a bird pet that has red color and 2 inches beak. Mary has a part time job that pays 10.5 an hour and usually Mary works 20 hours a week.

2. Print the object Mary

3. Create the object John Smith who is a graduate student and has a BA degree in Art. John has a dog and cat. John has a job that pays him 45,000.

4. Print the object John

5. Print the color of Marys bird

6. Print the salary of John

7. Mary adopted a cat. Add the cat to the object Mary. Choose whatever data you wish for the cat

8. Print the breed of the cat that Mary adopted

Input and output must be done using the console. DO NOT USE FILES or JOPTIONPANE.

4 provided classes:

mainClass:

package oop;

public class mainClass {

public static void main(String[] args) { } }

partTime:

package oop;

public class partTime extends Person { private double payRate; //store the pay rate private double pay; private double hoursWorked; //store the hours worked private pets myPet; //partTime employee has a pet. //default constructor public partTime() { super(); //default constrcutor of the superclass payRate = 0; hoursWorked = 0; pay=0; myPet = new pets(); }//end of default constructor

public partTime(String first, String last, double rate, double hours, String petName) { super(first,last ); payRate = rate; hoursWorked = hours; myPet= new pets(); myPet.setPetName(petName); calculatePay(); } //end of alternate

public void setPets(pets obj){ this.myPet.makeCopy(obj) ; }//end of setPets public void out(){ super.out(); System.out.println(lastName); System.out.println("I am in the child out method"); }//end of out

//Method to calculate and return the wages public void calculatePay() { pay= payRate * hoursWorked; }//end of calculatePay

public double getPay(){ return pay; }//end of getPay //Method to set the first name, last name, payRate, and public void setNameRateHours(String first, String last, double rate, double hours)

{ setName(first,last);//super is not required payRate = rate; hoursWorked = hours; }//end of setNAmeRateHours

//Method to return the pay rate //Postcondition: The value of payRate is returned public double getPayRate() { return payRate; }//end of getPayRate

//Method to return the number of hours worked public double getHoursWorked() { return hoursWorked; }//end of getHoursWorked //toString public String toString() { String str = super.toString(); str += " " + payRate+ " "+ hoursWorked + " "+ pay; str += " " + "Cat Information"+ " "; str+= myPet.toString(); return str; } }//end of parttime

Person:

package oop;

public class Person { protected String firstName; //store the first name protected String lastName; //store the last name private String ssn; //Default constructor public Person() { firstName = ""; lastName = ""; ssn="";

} //end of person public void out(){ System.out.println("I am in the parent out method"); } //Constructor with parameters: Alternate public Person(String first, String last, String ssn) { firstName = first; lastName = last; this.ssn = ssn; }//end of person public Person(String first, String last) { firstName = first; lastName = last; }//end of person //copy constructor public Person(Person obj){ this.firstName=obj.firstName; this.lastName= obj.lastName; }//end of Person //makeCopy public void makeCopy(Person obj){ this.firstName=obj.firstName; this.lastName= obj.lastName; }//end of makeCopy

//set name public void setName(String first, String last) { firstName = first; lastName = last; }

//Method to return firstName. public String getFirstName() { return firstName; }//end of getFirstName

//Method to return lastName. public String getLastName() { return lastName; }//end of getLastName //toString public String toString() { return (firstName + " " + lastName + " "+ssn); } //end of toString }//end of class Person

pets:

package oop;

public class pets { private String petName; private String breed; private String DOB;

public pets(String name){ this.petName=name; }

public void setPetName(String petName){ this.petName = petName; }

public String toString(){ return this.petName+ " " + breed + " "+ DOB; }

public String getPetName(){ return this.petName; }

}//end of pets

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

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions