Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA /** A class to demo the student and instructor subclasses. */ public class SchoolPersonTester { public static void main(String[] args) { SchoolPerson person

IN JAVA

/**

A class to demo the student and instructor subclasses.

*/

public class SchoolPersonTester

{

public static void main(String[] args)

{

SchoolPerson person = new SchoolPerson("Jeff", 2001);

SchoolPerson student = new Student("Ali",2002, "CS");

SchoolPerson instructor = new Instructor("Yeganeh", 1991, 120000);

System.out.println(person);

System.out.println(student);

System.out.println(instructor);

System.out.println("Expected: SchoolPerson Name: Jeff Year of Birth: 2001");

System.out.println("Student Name: Ali Year of Birth: 2002 Major: CS");

System.out.println("Instructor Name: Yeganeh Year of Birth: 1991 Salary: 120000");

}

}

/**

A class representing a person.

*/

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;

}

/**

Convert person to string form.

*/

public String toString()

{

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

}

}

PART A

/**

A class representing a student.

*/

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 maj)

{

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

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

// the new variable 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.

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

}

}

PART B

/**

A class representing an instructor.

*/

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 sal)

{

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

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

// the new variable 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.

//-----------------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_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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions