Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** A class representing an instructor at a school. You are to complete the following: - Complete the constructor - Complete the toString method */

/**

A class representing an instructor at a school. You are to complete the following:

- Complete the constructor

- Complete the toString method

*/

public class Instructor extends SchoolPerson

{

private int salary;

/**

Create an instructor with a given name and date of birth and salary.

@param name the name

@param yearOfBirth the date of birth

@param salary the salary

*/

public Instructor(String name, int yearOfBirth, int salary)

{

//-----------Start below here. To do: approximate lines of code = 2

// Initialize the inherited variables using super() and initialize

// the new variable salary

super(yearOfBirth, name);

this.salary = salary;

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

/**

Convert instructor to string form.

*/

public String toString()

{

//-----------Start below here. To do: approximate lines of code = 1

// override the method toString() and return a string

// containing the values of the inherited variables followed by

// " Salary: " followed by salary. Hint: make use of super.

return super.toString() + " Salary : " + salary;

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

}

NEXT CLASS

/**

A class representing a student at a school. You are to complete the following:

- Complete the constructor

- Complete the toString method

*/

public class Student extends SchoolPerson

{

private String major;

/**

Create a student with a given name and date of birth and major.

@param name the name

@param yearOfBirth the date of birth

@param major the major

*/

public Student(String name, int yearOfBirth, String major)

{

//-----------Start below here. To do: approximate lines of code = 2

// Initialize the inherited variables using super() and initialize

// the new variable major

super(yearOfBirth, name);

this.major = major;

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

/**

Convert student to string form

*/

public String toString()

{

//-----------Start below here. To do: approximate lines of code = 1

// override the method toString() and return a string

// containing the values of the inherited variables followed by

// " Major: " followed by major. Hint: make use of super.

return super.toString() + " Major : " + major;

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

}

NEXT CLASS

/**

A class representing a person at a school.

*/

public class SchoolPerson

{

private String name;

private int yearOfBirth;

/**

Create a person with a given name and date of birth.

@param name the name

@param yearOfBirth the date of birth

*/

public SchoolPerson(String name, int yearOfBirth)

{

this.name = name;

this.yearOfBirth = yearOfBirth;

}

public int getBirthYear()

{

return yearOfBirth;

}

/**

Convert person to string form.

*/

public String toString()

{

return this.getClass().getName() + " Name: " + name + " Year of Birth: " + yearOfBirth;

}

}

TESTER

import java.util.ArrayList;

/**

A class to test the student and instructor subclasses. In addition, you

are to complete the getOldest method which finds the oldest person in the

given array list and returns them

*/

public class SchoolPersonTester

{

/**

* Finds the oldest person in the given ArrayList and returns them. Returns null

* if the ArrayList is empty.

* @param people The list of people

* @return The oldest person in the array

*/

public static SchoolPerson getOldest(ArrayList people)

{

//-----------Start below here. To do: approximate lines of code = 5

//

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago