Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a class named Person and its two subclasses named Student and Faculty. Person class should have: name, age, and email. Constructor which takes

image text in transcribed imageimage

Design a class named Person and its two subclasses named Student and Faculty. Person class should have: name, age, and email. Constructor which takes 3 parameters for name, age and email. Student class should have: Major and gpa. Constructor which sets all necessary data in Person and Student class. toString method that lists student name, age, email, major and gpa. Method to register for a course. The method should make sure that the course has not reached max capacity and the student is not already in the course. Otherwise sysout a message and reject the student. Message can be generic. It is optional to specify the reason of rejection. (There is a method in the Course class that uses the same logic. Try to not duplicate it. Define the method either here or in Course class, then invoke it from the other place.) Faculty class should have: Department and office. toString method that lists faculty name, age, email, department and office Constructor which sets all necessary data in the Person and Faculty class. Design a class named Course. Course class should have: . department, course name, max class size, current enrollment number, roster (an array of students) and instructor. Constructor which takes 3 parameters for department, course name, and max class size. . toString method that lists course name, department, max class size, current enrollment number and instructor if one has been assigned. Method to display the class roster. Method to add one student at a time to the course. The method should make sure that the course has not reached max capacity and the student is not already in the course. Otherwise sysout a message and reject the student. Message can be generic. It is optional to specify the reason of rejection. (There is a method in the Student class that uses the same logic. Try to not duplicate it. Define the method either here or in Student class, then invoke it from the other place.) Method to assign an instructor to the class. Only the instructor from the same department can be assigned to the course. Use provided Registration Demo.java to test run your code. package mp; public class RegistrationDemo { public static void main(String[] args) { // TODO Auto-generated method stub //construct some students: Student jane = new Student("Jane", 20, "jane@wccnet.edu", "Computer Science", 3.45); Student kurtis = new Student("Kurtis", 36, "kurtis@wccnet.edu", "Math", 3.60); Student teddy = new Student("Teddy", 25, "Teddy@wccnet.edu", "Computer Science", 3.20); Student mike = new Student("Mike", 22, "Mike@wccnet.edu", "Biology", 3.58); Student sally = new Student("Sally",40, "Sally@wccnet.edu", "Computer Science", 3.80); Student nicole = new Student("Nicole",18,"kurtis@wccnet.edu", "Physics", 3.20); //construct course: Course introJava = new Course("CSIT", "Intro Java",5); System.out.println("------display course and roster:-----"); System.out.println(introJava); introJava.displayRoster(); // construct faculty: Faculty jing = new Faculty("Jing",40,"jswanson@wccnet.edu", "CSIT", "BE231"); Faculty jim = new Faculty ("Jim",35,"jim@wccnet.edu", "MATH", "GM200"); } } System.out.println(" ------assign instructor to the course: -----"); introJava.assignInstructor(jim); introJava.assignInstructor(jing);B System.out.println(" ------display course again: System.out.println(introJava); "); System.out.println(" ------adding some students to the course: -----"); introJava.addStudent (jane); introJava.addStudent (kurtis); introJava.addStudent (kurtis); introJava.addStudent (teddy); teddy.registerCourse(introJava); System.out.println(" ------display course again: -----"); System.out.println(introJava); System.out.println(" ------display roster:-----"); introJava.displayRoster(); System.out.println(" ------adding more students to the course: mike.registerCourse(introJava); sally.registerCourse(introJava); nicole.registerCourse (introJava); System.out.println(" ------display roster: --- -"); introJava.displayRoster(); ");

Step by Step Solution

There are 3 Steps involved in it

Step: 1

RegistrationDemojava class Person String name email int age public PersonString name int age String email thisname name thisage age thisemail email class Student extends Person String Major double gpa ... 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

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions