rite a class named Student. The class contains: ■ Private String data field “name” that refers to the name of the student. ■ Private integer data field “id” that refers to the student id. ■ Private Date data field “dateCreated” that refers to the current date when a new object Student is created. ■ A constructor that creates a new instance of the class student with the specified name and id. ■ Three methods named getName(), getID() and getDateCreated() that return
Write a class named Student. The class contains:
■ Private String data field “name” that refers to the name of the student.
■ Private integer data field “id” that refers to the student id.
■ Private Date data field “dateCreated” that refers to the current date when a
new object Student is created.
■ A constructor that creates a new instance of the class student with the specified
name and id.
■ Three methods named getName(), getID() and getDateCreated() that return
respectively the name, the id and the date when the student object was created.
■ A toString() method that return a String representation of the student.
2. Write a class named Course. The class contains:
■ Private String data field “courseName” that refers to the name of the course.
■ Private integer data field “capacity” that refers to the capacity of the course
(default value 10).
■ Private ArrayList of students that contains the students registered in the
course.
■ A constructor that creates a new course with the specified name.
■ A method named addStudent(Student s1) that add a specific student to the
course (if course is full, call the method overload).
■ A method named overloadStudent(Student s1) that overload a specific student
to the course (capacity should be increased by 1).
■ A method named dropStudent(Student s1) that drops a specific student from
the course (it should print “student not found” in case the student was not found
in the list).
■ A method named getStudents() that return the registered students in the
course.
■ A method named getNumberOfStudenstInCourse() that returns the number of
registered students in the course.
■ A method named getCourseName() that return the name of the course.
■ A toString() method that return a description of the course.
Write a program called testCourse to test your class. Below is a sample output
of the driver class after creating a course called “Computer Programming” and
adding 4 students to the course:
Computer Programming:
Thu Apr 22 11:37:40 EEST 2021: 202010, Peter Jones
Thu Apr 22 11:37:40 EEST 2021: 202015, Brian Smith
Thu Apr 22 11:37:40 EEST 2021: 202013, Anne Kennedy
Thu Apr 22 11:37:40 EEST 2021: 202080, Steve Smith
Step by step
Solved in 4 steps with 2 images