Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Create an application which represents a simplified course registration system using ArrayLists and HashMaps.

Define a class called Student with private attributes representing the student id (an int), the student's name (a String) and an ArrayList called regCourses containing Course objects that the student is registered in.

  • Create get methods for all 3 attributes.
  • Create a constructor that initializes attributes id, and name from incoming parameters, and initializes attribute regCourses to an empty ArrayList.
  • Create a toString() method that returns a string representing a student using the format as shown in the 2 examples below (Note: There is no comma at the end of the course lists):   

Define a class called Course with private attributes representing the department in which the course is offered (a Department object), the course code (e.g., 1406), the course name (e.g., "Introduction to Computer Science II") and a classList ArrayList containing Student objects who are registered in the course.

  • Create get methods for attributes code, department and classList.
  • Create a constructor that initializes attributes code, department and name from incoming parameters, and initializes classList to an empty ArrayList.
  • Create a toString() method that returns a string with the course code, course name and the number of people registered in the course in a format as shown in the following examples:

COMP1406 Introduction to Computer Science II, Enrollment = 238 
HIST1001 Canadian History, Enrollment = 12
 
Define a class called Department with private attributes representing the name (e.g., "Computer Science"), the departmental id (e.g., "COMP"), a courseList HashMap representing all courses offered by this department (with a course code as key and Course object as value) and a studentList ArrayList representing all students taking courses in this department.

  • Create get methods for all 4 attributes.
  • Create a constructor that creates a department whose name and id are specified as parameters and then also initializes the hashmap and array list to be empty.
  • Create a toString() method that shows the name and number of courses offered and students

registered in the department as follows:
School of Computer Science:  47 courses, 387 students
Make sure that ALL your code compiles at this point.   Test your code with the following program:

 public class TestProgram1 {
    public static void main(String[] args) {
     Department scs = new Department("School of Computer Science", "COMP");
  Department his = new Department("History", "HIST");
  System.out.println(scs);
  System.out.println(his);
 
  Course  c1406 = new Course(1406, scs, "Introduction to Computer Science II");
  Course  c1001 = new Course(1001, his, "Canadian History");
  System.out.println(c1406);
  System.out.println(c1001);
 
  Student matt = new Student(100239872, "Matt Adore");
  Student june = new Student(100125673, "June Bug");
  System.out.println(matt);
  System.out.println(june);
    }
}
 
It should have this output:
 
School of Computer Science: 0 courses, 0 students
History: 0 courses, 0 students
COMP1406 Introduction to Computer Science II, Enrollment = 0
HIST1001 Canadian History, Enrollment = 0
100239872 Matt Adore - Registered Courses: NONE
100125673 June Bug - Registered Courses: NONE 

(2) The "Meat":

1. Write a method in the Department class called offerCourse(Course c) that adds the given course to the department.   You may assume that the course is not already offered.

2. Write a method in the Department class called printCoursesOffered() that displays on the system console a list of all courses offered by the department.   Note that it should show all course information (i.e., use the toString() method).

3. Write a method in the Student class called isRegisteredInCourse(Course c) that returns a boolean which indicates whether or not the given student is registered in the given course.

4. Write a method in the Student class called registerFor(Course c) that causes the student to be registered for the given course.   If the student is already registered in the course, do nothing. Otherwise, update the appropriate Student, Course and Department objects as necessary.

5. Write a method in the Department class called printStudents() that displays on the system console a list of all students who are taking courses in this department.   Note that it should show all student information (i.e., use the toString() method).

6. Write a method in the Department class called isStudentRegistered(Student s) that returns a boolean which indicates whether or not the given student is registered for any course in this department.

7. Write a method in the Department class called studentsRegisteredInCourse(int code) that returns an ArrayList containing all students who are registered in the course with the given code.

8. Write a method in the Department class called printStudentsRegisteredInCourse(int code) that uses the method you just wrote to display on the system console a list of all students registered in the given course. This method should show only the id and name of the students.

9. Write a method in the Department class called largestEnrollment() which returns a Course object showing the course with the largest number of registered students. Note that if there are two or more courses with the same largest number, return either one.   You should use the values of the courseList hashmap.   Also, if there are no courses, null should be returned. 
 
10. Write a class (i.e., static) method in the Department class called areClassmates(Student s1, Student s2) which returns a boolean indicating whether or not these two students are taking any courses together. 

Java, Programming

  • Category:- Java
  • Reference No.:- M9131171
  • Price:- $35

Priced at Now at $35, Verified Solution

Have any Question?


Related Questions in Java

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As