Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Java code below shows how a set of classes work together to allow the following functionality: A Student object represents a students details (name,

The Java code below shows how a set of classes work together to allow the following functionality:

A Student object represents a students details (name, id number).

A Module object represents the details of a study module.

Each Student object can register for a number of Module objects.

A grade can be inserted for each Module object that the student has registered for.

Each Module object can print out the list of students that have registered for it.

Each Module object can print out a list of students ranked by the mark they received.

image text in transcribed

(a) Write the Java code for the Student and Module classes making appropriate use of constructor, access modifiers and getter/setter methods.

(b) What data structure could be used in the Student class to record the Modules that a Student has registered for? Explain your answer and show how this would be implemented in Java.

(c) In the code above, a Module object does not appear to explicitly receive a list of the students that have registered with it. However, it can still produce a listing of students. Show how a Module object receives and stores each students details and grade information.

(d) lines 28 and 29 shows a method called rankStudents being called. This method prints out a list of Student names ranked according to their mark in the module. Show how this would be implemented.

5e public static void main(String args) Student skelly= new Student("Sean", "Kelly", 1245780); Student mkehoe new Student(" May", "Kehoe", 12678889); 7 10 Module oop = new Module("OO programming", "CT2106"); Module thermo- new ModuleC"Thermodynamics", "CT2332"); 12 13 14 15 16 17 18 19 20 21 skelly.registerForModule(oop); skelly.registerForModule(thermo); mkehoe.registerForModule(oop); mkehoe.registerForModuleCthermo); skelly.insertGradeCoop, 65); skelly.insertGrade(thermo, 72); mkehoe.insertGradeCoop, 48); mkehoe.insertGrade(thermo, 77); 23 24 25 26 27 28 29 30 31 32 oop.listO; thermo.listO; oop.rankStudentsO; thermo.rankStudentsO: oop.printO; thermo.printo

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

Step: 3

blur-text-image

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions