Question: In this question, you are to create a Student class as a subclass of the Person class from Class Assignment 1 and a StudentTest class

 In this question, you are to create a Student class as

a subclass of the Person class from Class Assignment 1 and a

In this question, you are to create a Student class as a subclass of the Person class from Class Assignment 1 and a StudentTest class to test the Student class. First, create a Student class as a subclass of the Person class. Add the following private data fields to the Student class: - school, which is of type String and represents the school a student attends. - courses, which is an ArrayList of strings each representing a course the student has taken. Initialize it to an empty list. Add the following methods to the Student class: - A constructor public Student (String name, String gender, int age, int height, String school) that initializes the data fields with the values of the corresponding arguments. Be sure to use the super keyword to initialize the data fields of the superclass (i.e., the Person class). - A toString method that which overrides that of the superclass (i.e., the Person class) and returns a string of the form (Name: Gender: Age: School: , Courses: where the underscores should be replaced with the values of the corresponding fields. Be sure to call the toString method of the superclass (i.e., the Person class) for the data fields from superclass and append to the result the fields pertaining to the Student class. - A method public void takeCourse (String course) that adds the given course to the courses list. Create a main method in the StudentTest class. In the main method, - Create a Student object named alice, with "Alice" for name, "Female" for gender, 18 for age, 65 for height, and "GGC" for school. Print the object to the console. - Call the talk method of Alice for her to talk and print the result to the console. Your code should print Hello! I am Alice. - Call the takeCourse method of Alice for her to take "ITEC 2140", "ITEC 2150" and "ITEC 3150 "in this order. - Print Alice to the console. Your code should print (Name: Alice, Gender: Female, Age: 18, Height: 65, School: GGC, Courses: [ITEC 2140, ITEC 2150, ITEC 3150])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!