Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

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

Step: 3

blur-text-image

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

What would you do?

Answered: 1 week ago