Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Generics and collections java task with explaination: Person Abstract class that contains private properties for idNumber and name, along with appropriate getter and setter methods

Generics and collections java task with explaination:

Person Abstract class that contains private properties for idNumber and name, along with appropriate getter and setter methods for these properties. Lecturer Should extend Person, and provide a teachesUnit(Unit u) and dropUnuit(Unit u) method, to keep track of which units a lecturer teaches. The Lecturer class will also need a getAllUnitsTaught() method, which will return an ArrayList of units that this Lecturer teaches. Note: each unit is only taught by one Lecturer in this example (one-to-many relationship). Student Should extend Person, and provide a takesUnit(Unit u) and dropUnit(Unit u) method, to keep track of which units a student takes. The Student class will also need a getAllUnitsTaken() method that returns an ArrayList of units that this student takes. Note: Many students can take a unit, and a student may take many units (many-to-many relationship). Unit Will need a getLecturer() and setLecturer(Lecturer l) method to keep track of the Lecturer teaching the unit, as well as enrolStudent(Student s) and removeStudent(Student s) to keep track of the students taking the unit. The Unit class will also need a getTitle() and setTitle(String s) method to allow each unit to be given a name. The Lecturer, Student and Unit classes will each need an ArrayList to keep track of their related entities.

Create your own Test Data for Tasks Write a simple class, with a constructor method, to construct the your own object graph, manipulating all of the Units, Lecturers & Students. You will also need to create associations between objects (i.e. update Lecturer A to show that they teachs unitA, and update UnitA to show that its taught by Lecturer A etc.

test your code by creating a main() method that constructs an instance of your class, thus creating the lecturers, units and students, and then calls the method for each exercise in turn.

Print out the name of each of the units taken by Student A. 2. Print out the names and ID numbers of all the students taught by Lecturer A. 3. Print out the names of all of the units taken by more than two students. 4. Print out the names of all of the students not taught either by Lecturer A or by Lecturer B. 5. Print out the name of the most popular unit.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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_2

Step: 3

blur-text-image_3

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions