Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java Step 1 : Person 1 . Write a class called Person ( this class cannot be instantiated ) . Now add the following

in java
Step 1: Person
1. Write a class called Person (this class cannot be instantiated). Now add the following fields and mark them private:
firstName, lastName (String)
age (int)
2. Add a constructor that takes the first and last name and age as parameters and initializes the fields above.
3. Add an abstract method, goAboutDay, that takes no parameters and returns nothing (void)
4. Add a toString that renders the Person like so:
Person: [firstName],[lastName]- age: [age]
Step 2: ISalaried
Create an interface, ISalaried, that exports a single abstract method: getSalary() with a return type of double.
Step 3: Student
1. Now write a Student class (this class can be able to be instantiated). Make the class extend Person.
2. Add a constructor that takes the same parameters as Person and super them up via a super(..) call in the constructor.
3. Override the goAboutDay() method and make it print: "studying, class, beer, bed"
Step 4: GraduateStudent
1. Create a class GraduateStudent that can be instantiated. Make the class extend Student.
2. Make the constructor accept a first name, last name, an age, and a list of courses (of type List) store the courses into a field and super up the rest to the student class constructor.
3. Now make this class implement ISalaried.
when you go implement the getSalary() method required by the interface, the implementation for should return $10.00 if they are teaching 15 or more courses, $0 otherwise.
4. Override the goAboutDay() method and have it print: "bed, writing, reading, teaching, class"
Step 5: Instructor
1. Create an instructor class that extends Person and implements Salaried. This class should be able to be instantiated.
2. Add two private fields:
yearlySalary (type: double)
activeCourses (type: List)
3. Add a constructor that matches the superclass constructor and adds parameters for the yearlySalary and List containing the courses being actively taught by the instructor. Initialize the two fields above using these parameters.
4. Override the getSalary() method. If the activeCourses list is empty, make the method return $0; otherwise make it return yearlySalary.
5. Override the goAboutDay() method and make it print: "teaching, grading, tv, bed"
Step 6: Tester
Create a Tester class with a main(..) method. Instantiate a GraduateStudent and an Instructor (make the declared type for these variables ISalaried). Print out each variables salary by calling the getSalary() method.

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_2

Step: 3

blur-text-image_3

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

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

More Books

Students also viewed these Databases questions

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago