Within My Ownership previously —a car rental service that specializes in lending
ID: 3622768 • Letter: W
Question
Within My Ownership previously —a car rental service that specializes in lending antique and luxury cars to clients on a short-term basis. You created the logic for the following classes: Name, Address, Date, Employee, Customer, Automobile, and Rental Agreement.Complete the superclass named Person from which both Employee and Customer descend from. Attributes and methods that any Person should possess—for example, a name and address are passed to the Employee and Customer classes. Then rewrite the Employee and Customer classes to descend from Person, including only attributes and methods appropriate for each subclass.
· class Person
· // Declarations
· private Name ______
· private Address ______
· public void setName(Name nm)
· ______ = nm
· return
· public void setAddress(Address ______)
· address = add
· return
· public Name getName()
· return ______
· public Address getAddress()
· return ______
· end______
· class Employee inheritsFrom ______
· // Declarations
· private string idNumber
· private Date hireDate
· protected num hourlyPayRate
· public void setIdNumber(string id)
· idNumber = ______
· return
· public void set______ (Date hDate)
· hireDate = ______
· return
· public void setHourlyPayRate(num rate)
· hourlyPayRate = ______
· return
· public string getIdNumber()
· return ______
· public Date getHireDate()
· return ______
· public num getHourlyPayRate()
· return ______
· endClass
· class Customer inheritsFrom Person
· // Declarations
· protected string idNumber
· public void setIdNumber(string id)
· idNumber = id
· return
· public string getIdNumber()
· return idNumber
· endClass
· class PartTimeEmployee inheritsFrom ______
· // Declarations
· private num weeklyHours
· private num taxRate
· class FullTimeEmployee inheritsFrom Employee
· // Declarations
· private num yearlySalary
· public void setYearlySalary(num sal)
· // Declarations
· num TOTAL_YRLY_HRS = 2080
· yearlySalary = ______
· hourlyPayRate = yearlySalary / TOTAL_YRLY_HRS
· return
· public void setHourlyPayRate(num rate)
· // Declarations
· num TOTAL_YRLY_HRS = 2080
· hourlyPayRate = rate
· yearlySalary = hourlyPayRate * TOTAL_YRLY_HRS
· return
· public num getYearlySalary()
· return yearlySalary
· endClass
Explanation / Answer
// answers are in red colour observe it !!
· class Person
· // Declarations
· private Name name
· private Address address
· public void setName(Name nm)
· name = nm
· return
· public void setAddress(Address add)
· address = add
· return
· public Name getName()
· return name
· public Address getAddress()
· return address
· end Person
· class Employee inheritsFrom Person
· // Declarations
· private string idNumber
· private Date hireDate
· protected num hourlyPayRate
· public void setIdNumber(string id)
· idNumber = id
· return
· public void setHireDate (Date hDate)
· hireDate = hDate
· return
· public void setHourlyPayRate(num rate)
· hourlyPayRate = rate
· return
· public string getIdNumber()
· return idNumber
· public Date getHireDate()
· return hireDate
· public num getHourlyPayRate()
· return hourlyPayRate
· endClass
· class Customer inheritsFrom Person
· // Declarations
· protected string idNumber
· public void setIdNumber(string id)
· idNumber = id
· return
· public string getIdNumber()
· return idNumber
· endClass
· class PartTimeEmployee inheritsFrom Employee
· // Declarations
· private num weeklyHours
· private num taxRate
· class FullTimeEmployee inheritsFrom Employee
· // Declarations
· private num yearlySalary
· public void setYearlySalary(num sal)
· // Declarations
· num TOTAL_YRLY_HRS = 2080
· yearlySalary = 10000
· hourlyPayRate = yearlySalary / TOTAL_YRLY_HRS
· return
· public void setHourlyPayRate(num rate)
· // Declarations
· num TOTAL_YRLY_HRS = 2080
· hourlyPayRate = rate
· yearlySalary = hourlyPayRate * TOTAL_YRLY_HRS
· return
· public num getYearlySalary()
· return yearlySalary
· endClass
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.