SchoolPersonTester.java /** A class to demo the student and instructor subclasses. */ public class SchoolPersonTester { public
Question:
SchoolPersonTester.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");
}
}
SchoolPerson.java
/**
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;
}
}
Student.java
/**
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.
}
}
Instructor.java
/**
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.
}
}
P.s: please besides the code, also include a screenshot of code, and the output to confirm code doesn't get edited out and the output satisfies the problem!!
Elementary Statistics A step by step approach
ISBN: 978-0073386102
8th edition
Authors: Allan Bluman