Question 1: Write a student class to represent students. Each student has a name, a unique...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 1: Write a student class to represent students. Each student has a name, a unique ID, and a phone number. Students can choose to add courses or drop courses. No student has access to the research lab, but a student has access to the library if he/she is taking at least one course. The Student class should have the following public interface: 1. public Student(String name, String phoneNumber): A constructor to set up student's name, phone number, and ID. Hint: Follow the BankAccount example discussed under the topic "Designing Classes" to generate the ID for each student object. 2. public String getStudentName(): An accessor to return the student's name. 3. public String getStudentPhone(): An accessor to return the student's phone number. 4. public int getStudentId(): An accessor to return the student's ID. 5. public boolean addCourse(String courseName): A method to add courses. The max course load of each student is five courses. Any attempt to add more than five courses will fail and this method will return false. Return true when the course is added successfully. 6. public boolean dropCourse(String courseName): A method to drop a course. This method will remove the course from the student's course load. If there is no such course in the student's course load or the student has not enrolled in any course, the method will return false. 7. public int getCourseCount(): A method to return the number of courses that student has enrolled. 8. public boolean hasAccessToLibrary(): A method that indicates whether the student has access to the library. If the number of courses enrolled is greater than zero, the student will have the access to library. 9. public boolean hasAccessToResearchLab(): A method that indicates whether the student has access to the research lab. Return false. Note that in the implementation above, use only the language elements that were covered in Weeks 1 -3 (September 7, 14, and 21). Write a tester program Task1Tester to thoroughly test the class you have written. Follow the examples given in class (See Slides 42-44 of "Implementing Classes" posted on eClass). This tester class is to help you make sure your Student class works as intended. persons Question 2: Now consider the more general case where we would like to model other types of beyond Student. For this, we design a hierarchy of classes to represent the different types of people. At the top of the class hierarchy, write an abstract class called Person with methods common to different types of people. Person has the following public interface: 1. public Person(String name, String phoneNumber, String type): A constructor to initialize the person's name and phone number. Hint: Follow the BankAccount example discussed under the topic "Designing Classes" to generate the ID for each person object. 2. public String getName(): An accessor to return the person's name. 3. public String getPhoneNumber(): An accessor to return the person's phone number. 4. public int getId(): An accessor to return the person's id. 5. public String getType(): An accessor to return a string that represents the type of person. 6. public abstract boolean hasAccessToLibrary(): A method that indicates whether the person has access to the library. This should be overridden by the subclass. 7. public abstract boolean hasAccessToResearchLab(): A method that indicates whether the person has access to the research lab. This should be overridden by the subclass. Once Person is defined, you must then provide a different implementation of the student concept above with a new class name Student2 and define a new class Instructor, both of which inherit from Person: Student2 should be implemented to keep the attributes and behaviors specified in Question 1. The class Instructor represents instructors. All instructors have access to the library. Assume that each instructor is assigned to teach one course and this assignment will not change. Each instructor may also have a research project, and only instructors having a research project can access the research lab.should have the following public interface: 1. public Instructor(String name, String phoneNumber, String courseId): A constructor to set up the instructor name, phone number and course. Each instructor should have a unique ID just like in Student and Person. ● 2. public boolean setReserachProject(String project): A method to set the research project for the instructor. If the instructor has already had a project, the old project will be replaced by the given project. 3. public String getProject(): return the research topic of the instructor. 4. public boolean hasAccessToLibrary(): A method that indicates whether the instructor has access to the library. Always return true. 5. public boolean hasAccessToResearch Lab(): A method that indicates whether the instructor has access to the research lab. Return true if the research topic is set; false otherwise. Write a tester program Task2Tester to test Student2 and Instructor classes you have written in Question 2. Question 1: Write a student class to represent students. Each student has a name, a unique ID, and a phone number. Students can choose to add courses or drop courses. No student has access to the research lab, but a student has access to the library if he/she is taking at least one course. The Student class should have the following public interface: 1. public Student(String name, String phoneNumber): A constructor to set up student's name, phone number, and ID. Hint: Follow the BankAccount example discussed under the topic "Designing Classes" to generate the ID for each student object. 2. public String getStudentName(): An accessor to return the student's name. 3. public String getStudentPhone(): An accessor to return the student's phone number. 4. public int getStudentId(): An accessor to return the student's ID. 5. public boolean addCourse(String courseName): A method to add courses. The max course load of each student is five courses. Any attempt to add more than five courses will fail and this method will return false. Return true when the course is added successfully. 6. public boolean dropCourse(String courseName): A method to drop a course. This method will remove the course from the student's course load. If there is no such course in the student's course load or the student has not enrolled in any course, the method will return false. 7. public int getCourseCount(): A method to return the number of courses that student has enrolled. 8. public boolean hasAccessToLibrary(): A method that indicates whether the student has access to the library. If the number of courses enrolled is greater than zero, the student will have the access to library. 9. public boolean hasAccessToResearchLab(): A method that indicates whether the student has access to the research lab. Return false. Note that in the implementation above, use only the language elements that were covered in Weeks 1 -3 (September 7, 14, and 21). Write a tester program Task1Tester to thoroughly test the class you have written. Follow the examples given in class (See Slides 42-44 of "Implementing Classes" posted on eClass). This tester class is to help you make sure your Student class works as intended. persons Question 2: Now consider the more general case where we would like to model other types of beyond Student. For this, we design a hierarchy of classes to represent the different types of people. At the top of the class hierarchy, write an abstract class called Person with methods common to different types of people. Person has the following public interface: 1. public Person(String name, String phoneNumber, String type): A constructor to initialize the person's name and phone number. Hint: Follow the BankAccount example discussed under the topic "Designing Classes" to generate the ID for each person object. 2. public String getName(): An accessor to return the person's name. 3. public String getPhoneNumber(): An accessor to return the person's phone number. 4. public int getId(): An accessor to return the person's id. 5. public String getType(): An accessor to return a string that represents the type of person. 6. public abstract boolean hasAccessToLibrary(): A method that indicates whether the person has access to the library. This should be overridden by the subclass. 7. public abstract boolean hasAccessToResearchLab(): A method that indicates whether the person has access to the research lab. This should be overridden by the subclass. Once Person is defined, you must then provide a different implementation of the student concept above with a new class name Student2 and define a new class Instructor, both of which inherit from Person: Student2 should be implemented to keep the attributes and behaviors specified in Question 1. The class Instructor represents instructors. All instructors have access to the library. Assume that each instructor is assigned to teach one course and this assignment will not change. Each instructor may also have a research project, and only instructors having a research project can access the research lab.should have the following public interface: 1. public Instructor(String name, String phoneNumber, String courseId): A constructor to set up the instructor name, phone number and course. Each instructor should have a unique ID just like in Student and Person. ● 2. public boolean setReserachProject(String project): A method to set the research project for the instructor. If the instructor has already had a project, the old project will be replaced by the given project. 3. public String getProject(): return the research topic of the instructor. 4. public boolean hasAccessToLibrary(): A method that indicates whether the instructor has access to the library. Always return true. 5. public boolean hasAccessToResearch Lab(): A method that indicates whether the instructor has access to the research lab. Return true if the research topic is set; false otherwise. Write a tester program Task2Tester to test Student2 and Instructor classes you have written in Question 2.
Expert Answer:
Answer rating: 100% (QA)
Question 1 Answer Below is an implementation of the Student class as described followed by a simple tester program named Task1Tester import javautilArrayList class Student private String name private ... View the full answer
Related Book For
Modern Database Management
ISBN: 978-0133544619
12th edition
Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi
Posted Date:
Students also viewed these programming questions
-
Determine the slope of the line tangent to the graph of - 8 at x = 13. Enter your answer as a f(x) = 3 arcsin(x)+2-8 at x= simplified fraction. m =
-
According to the Adapting to Change box, what is the professional is best able to detect the financial irregularities that often accompany fraud in an organization?
-
Business Process, Inc. (BPI), a consulting company offering business process reengineering and application system development expertise, wants to develop a prototype of a simple University...
-
Role-play a human resources manager trying to convince the company CEO and two of his executives (role-played by three students) that introducing some of the rewards discussed in the case opening is...
-
Why is it not possible to enforce memory protection at compile time?
-
Consider the Intel address translation scheme shown in Figure 8.22. a. Describe all the steps that the Intel 80386 takes in translating a logical address into a physical address. b. What are the...
-
What is the most important feature of a driving point FRF?
-
Shawnee Co. set up a petty cash fund for payments of small amounts. The following transactions involving the petty cash fund occurred in May (the last month of the companys fiscal year). May 1...
-
A radar gun was used to record the speed of a runner during the first 5 seconds of a race (see the table). Use Simpson's Rule to estimate the distance the runner covered during those 5 seconds....
-
SecuriCorp operates a fleet of armored cars that make scheduled pickups and deliveries in the Los Angeles area. The company is implementing an activity-based costing system that has four activity...
-
As potential energy can be converted to kinetic energy and vice versa. Provide an example of energy being converted from potential to kinetic energy (or vice vera) and explain how you would determine...
-
Consider your chosen careers, relationships, and interactions with others. Regardless of your chosen major or career field, it is important to be a competent communicator. Through your knowledge of...
-
Evaluate 14 1 10 10 6 11 24
-
At a bank, services offered include home loans, personal loans and savings accounts. The home loans process has a demand of 13 customers per day. The personal loans process has demand of 8 customers...
-
Explains: 1. Given one BGP neighbor's AS 65000 with address 2001:db8:cccc:cccc::1234/64, and this neighbor is directly connected with another BGP neighbor, what is the BGP configuration on a Cisco...
-
Scenario: You are working for a company that is hoping to adapt a short story into a film. Your supervising director had not read "The Happy Prince" by Oscar Wilde, and since she doesn't have time to...
-
Find the Taylor series solution with three terms for the initial value problem = x + y, y(1) = 1 Solution: dx
-
Use the T account for Cash below to record the portion of each of the following transactions, if any that affect cash. How do these transactions affect the companys liquidity? Jan. 2 Provided...
-
Are associative entities also weak entities? Why or why not? If yes, is there anything special about their "weakness"?
-
Whitlock Department Stores runs a multiuser DBMS on a LAN file server. Unfortunately, at the present time, the DBMS does not enforce concurrency control. One Whitlock customer had a balance due of...
-
Describe the current key trends in data warehousing.
-
The payments set out in Table 9.9 have been made during the year in relation to a non-current asset bought at the beginning of the year. What cost figure should be used as the basis for the...
-
Outline three different depreciation methods and appraise them in the context of the definition and objectives of depreciation.
-
The following actual and estimated figures are available. Based on these figures, evaluate the following. a. Calculate annual depreciation under the straight-line method. b. Calculate the...
Study smarter with the SolutionInn App