In this assignment, you will make two classes,Student and Instructor, that inherit from a superclass Person. The implementation of class Person is given below. public class Person { private String name; private int age; public Person() { name=""; age=0; } /** Create a person with a given name and age. @param name the name @param age the age */ public Person(String name, int age) { this.name = name; this.age = age; } /** Get the name. @return the name */ public String getName() { return name; } /** Change the name. @param name the name */ public void setName(String name) { this.name = name; } /** Get the age. @return the age */ public int getAge() { return age; } /** Change the age. @param age the age */ public void setAge() { this.age = age; } /** Convert person to string form. */ public String toString() { return "Name: " + name + "\t" + "Age: " + age; } } You will also need to write a test program to test the methods you write for these two classes. The implementation details are described as follows. Stage 1:In the first file Student.java, you should include the following additional instance variables and methods (other than all instance variables and methods inherited from class Person): •Private instance variables studentID, and major; •A constructor takes four inputs (name, age, studentID and major); •Two additional getter methods to return each of instance variables (accessor); •Two setter methods to change each of instance variables (mutator); •A method toString that converts a student’s information into string form. The string should have the format as shown in Figure 1. You should override superclass toString( )method. •A method compareTo that implements the interface Comparable, so that Student objects can be sorted by studentID in an ascending order. Stage 2: In the second file Instructor.java, you should include the following additional instance variables and methods (other than all instance variables and methods inherited from class Person): •Private instance variable salary; •A constructor takes three inputs (name ,age, and salary); •One additionalgetter method to return the instance variable (accessor); •One setter method to change the instance variable (mutator); •A method toString that converts an instructor’s information into string form. The string should have the format as shown in Figure 1. Specifically, you need to format salary value to 2 decimal places, and make them right aligned. You should also override superclass toString() method. •A method compareTo that implements the interface Comparable, so that Instructor objects can be sorted by salary in an ascending order. Stage 3: In the third filePersonTester.java, you will need to do the followings: 1. You need to read data file “data1.txt” into an array of Student objects, Specifically, (a) The first number in the first line of the file is used to determine the array size. (b) The remaining lines are the student records. You will need to create a Student object using each line’s information, and put it into the array. 2. Do sorting of the initialized array of Student objects, and then print them out. The outputs should be nicely labeled and formatted, as shown in Figure 1. 3. Repeat the above steps to read data file “data2.txt” into an array of Instructor objects, do sorting and print them out. The outputs should be nicely labeled and formatted, as shown in Figure 1. To avoid code redundancy, you may use a loop to handle the repetitive procedure.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

In this assignment, you will make two classes,Student and Instructor, that inherit from a superclass Person. The implementation of class Person is given below.

public class Person
{
private String name;
private int age;


public Person()
{
name="";
age=0;
}
/**
Create a person with a given name and age.
@param name the name
@param age the age
*/
public Person(String name, int age)
{
this.name = name;
this.age = age;
}

/**
Get the name.
@return the name
*/
public String getName()
{
return name;
}

/**
Change the name.
@param name the name
*/
public void setName(String name)
{
this.name = name;
}

/**
Get the age.
@return the age
*/
public int getAge()
{
return age;
}

/**
Change the age.
@param age the age
*/
public void setAge()
{
this.age = age;
}


/**
Convert person to string form.
*/

public String toString()
{
return "Name: " + name + "\t" + "Age: " + age;
}

}

You will also need to write a test program to test the methods you write for these two classes. The implementation details are described as follows. Stage 1:In the first file Student.java, you should include the following additional instance variables and methods (other than all instance variables and methods inherited from class Person):

•Private instance variables studentID, and major;

•A constructor takes four inputs (name, age, studentID and major);

•Two additional getter methods to return each of instance variables (accessor);

•Two setter methods to change each of instance variables (mutator);

•A method toString that converts a student’s information into string form. The string should have the format as shown in Figure 1. You should override superclass toString( )method.

•A method compareTo that implements the interface Comparable, so that Student objects can be sorted by studentID in an ascending order.

Stage 2: In the second file Instructor.java, you should include the following additional instance variables and methods (other than all instance variables and methods inherited from class Person):

•Private instance variable salary;

•A constructor takes three inputs (name ,age, and salary);

•One additionalgetter method to return the instance variable (accessor);

•One setter method to change the instance variable (mutator);

•A method toString that converts an instructor’s information into string form. The string should have the format as shown in Figure 1. Specifically, you need to format salary value to 2 decimal places, and make them right aligned. You should also override superclass toString() method.

•A method compareTo that implements the interface Comparable, so that Instructor objects can be sorted by salary in an ascending order.

Stage 3: In the third filePersonTester.java, you will need to do the followings:

1. You need to read data file “data1.txt” into an array of Student objects, Specifically,

(a) The first number in the first line of the file is used to determine the array size.

(b) The remaining lines are the student records. You will need to create a Student object using each line’s information, and put it into the array.

2. Do sorting of the initialized array of Student objects, and then print them out. The outputs should be nicely labeled and formatted, as shown in Figure 1.

3. Repeat the above steps to read data file “data2.txt” into an array of Instructor objects, do sorting and print them out. The outputs should be nicely labeled and formatted, as shown in Figure 1. To avoid code redundancy, you may use a loop to handle the repetitive procedure.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education