Design a class named Person and its two subclasses named Student and Faculty. Person class should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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("\n\n------assign instructor to the course: -----"); introJava.assignInstructor(jim); introJava.assignInstructor(jing);B System.out.println("\n\n------display course again: System.out.println(introJava); "); System.out.println("\n\n------adding some students to the course: -----"); introJava.addStudent (jane); introJava.addStudent (kurtis); introJava.addStudent (kurtis); introJava.addStudent (teddy); teddy.registerCourse(introJava); System.out.println("\n\n------display course again: -----"); System.out.println(introJava); System.out.println("\n\n------display roster:-----"); introJava.displayRoster(); System.out.println("\n\n------adding more students to the course: mike.registerCourse(introJava); sally.registerCourse(introJava); nicole.registerCourse (introJava); System.out.println("\n\n------display roster: --- -"); introJava.displayRoster(); "); 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("\n\n------assign instructor to the course: -----"); introJava.assignInstructor(jim); introJava.assignInstructor(jing);B System.out.println("\n\n------display course again: System.out.println(introJava); "); System.out.println("\n\n------adding some students to the course: -----"); introJava.addStudent (jane); introJava.addStudent (kurtis); introJava.addStudent (kurtis); introJava.addStudent (teddy); teddy.registerCourse(introJava); System.out.println("\n\n------display course again: -----"); System.out.println(introJava); System.out.println("\n\n------display roster:-----"); introJava.displayRoster(); System.out.println("\n\n------adding more students to the course: mike.registerCourse(introJava); sally.registerCourse(introJava); nicole.registerCourse (introJava); System.out.println("\n\n------display roster: --- -"); introJava.displayRoster(); ");
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
explain concept intervention and impact of stressor, stress, and strain as it relates to psychological hazard.
-
Diagram C 10 points Draw a diagram explaining and labeling Healthcare Transaction C. Healthcare Transaction C: Paula is 68 years old and has Medicare Part C coverage; she is enrolled in a Medicare...
-
Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student...
-
Prepare journal entries to record each of the following transactions. The company records purchases using the gross method and a perpetual inventory system. June 1 9 Purchased merchandise with a...
-
Write the following models of frequency dependence as systems of autonomous differential equations for a and b. 1. The situation in Section 5.1, Exercise 37. 2. The situation in Section 5.1, Exercise...
-
The heat of hydration of dough, which is 15 kJ/kg, will raise its temperature to undesirable levels unless some cooling mechanism is utilized. A practical way of absorbing the heat of hydration is to...
-
What is the salary amount for Paul Boswell?
-
Donaldson Incorporated sold $500,000 of 12% bonds on January 1, 2006 for $470,143.47, a price that yields a 14% interest rate. The bonds pay interest semiannually on June 30 and December 31 and are...
-
Suppose the probability of an event is 0.80. What are the odds in favor of this event?
-
The bar codes above represent locations in a warehouse. How many units would be left in each location? If you picked 250 units from location 00000113774360000 If you picked 250 units from location 00...
-
Under this method, it attempts to figure out the value of an investment today, based on projections of how much money it will generate in the future. a. Capitalization of Earnings method b. Income...
-
Elements of negligence Duty to care: The legal obligation or obligatory conduct owed by one person to another. The standard of care is the conduct expected of an individual in a given situation. ...
-
Mediation is the process wherein a third party attempts to bring about a settlement between parties. Arbitration is a process wherein parties agree to submit their differences to the judgment of an...
-
Describe the defenses often used in a products liability case.
-
Products liability defenses include: Assumption of a risk Intervening cause Contributory negligence Comparative fault Disclaimers
-
Structured awards are those placed in a trust set up to provide compensation over a plaintiffs lifetime.
-
Question #1 Question #2 Question #3 Question #4 Question #5 . You are offered the opportunity to put some money away for retirement. You will receive five annual payments of $25,000 each...
-
Refrigerant R-12 at 30C, 0.75 MPa enters a steady flow device and exits at 30C, 100 kPa. Assume the process is isothermal and reversible. Find the change in availability of the refrigerant.
-
Write a program that reads the following information and prints a payroll statement: Employee?s name (e.g., Smith) Number of hours worked in a week (e.g., 10) Hourly pay rate (e.g., 9.75) Federal tax...
-
Write a program that views, inserts, and updates staff information stored in a database, as shown in Figure 32.27a. The View button displays a record with a specified ID. The Insert button inserts a...
-
Find the first ten numbers with 50 decimal digits that are divisible by 2 or 3.
-
Three bases of position power are ____________. (a) reward, expertise, and coercive power (b) legitimate, experience, and judgment power (c) knowledge, experience, and judgment power (d) reward,...
-
What are power and influence?
-
What are the key sources of power and influence?
Study smarter with the SolutionInn App