Instructions:
You are about to write an object-oriented program using inheritance and polymorphism to simulate a student tracking system. You'll consider adding the following classes in your design:
A skeleton code for class TestStudent:
public class TestStudent { public static void main(String[] args) { University wesleyan = new University("Texas Wesleyan University, Fort Worth, Texas"); University rice = new University("Rice University, Houston, Texas"); University cornell = new University("Cornell University, Ithaca, New York"); Person jackiePerez = new CollegeStudent("Jackie Perez", 21, 3.58, "Computer Science", wesleyan); System.out.println("\n---------------------- 1 ---------------------"); jackiePerez.print(); Person erikaSmart = new CollegeStudent("Erika Smart", 25, 2.3, "Biology", rice); System.out.println("\n---------------------- 2 ---------------------"); erikaSmart.print(); if (erikaSmart instanceof CollegeStudent) ((CollegeStudent)erikaSmart).changeMajor("General Business"); System.out.println("\n---------------------- 3 ---------------------"); erikaSmart.print(); Student joMiller = new CollegeStudent("Jo Miller", 19, 2.85, "Liberal Arts", new University()); System.out.println("\n---------------------- 4 ---------------------"); joMiller.print(); CollegeStudent veronikaVasylenko = new CollegeStudent("Veronika Vasylenko", 22, 3.95, "Mechanical Engineering", cornell); System.out.println("\n---------------------- 5 ---------------------"); veronikaVasylenko.print(); System.out.println("\n" + Person.getPersonCount() + " Person objects have been created."); } }
// ---------------------- 1 --------------------- // Jackie Perez is 21 years old. GPA is 3.58. // Made Dean's honor list. // Major in Computer Science. // Attending Texas Wesleyan University, Fort Worth, Texas // ---------------------- 2 --------------------- // Erika Smart is 25 years old. GPA is 2.3. // Major in Biology. // Attending Rice University, Houston, Texas // ---------------------- 3 --------------------- // Erika Smart is 25 years old. GPA is 2.3. // Major in General Business. // Attending Rice University, Houston, Texas // ---------------------- 4 --------------------- // Jo Miller is 19 years old. GPA is 2.85. // Major in Liberal Arts. // Attending The university name has not been provided. // ---------------------- 5 --------------------- // Veronika Vasylenko is 22 years old. GPA is 3.95. // Made Dean's honor list. // Major in Mechanical Engineering. // Attending Cornell University, Ithaca, New York // 4 Person objects have been created.