Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with my java homework. The code will be below. Enter from console the student code, and we get all the information about

I need help with my java homework. The code will be below.

Enter from console the student code, and we get all the information about the student. Enter the code of the course and we get all the information about course. Write and read the information of the enrollments in file using serialized class Enrollment. Add a method in Controller that displays for each course the respective number of the students.

package com.example;

import java.io.Serializable; import java.util.ArrayList;

public class Course implements Serializable { private String code; private String description; private int credits; private ArrayList cEnrollments; public Course(String code, String description, int credits) { super(); this.code = code; this.description = description; this.credits = credits; cEnrollments=new ArrayList(); } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public int getCredits() { return credits; } public void setCredits(int credits) { this.credits = credits; } public ArrayList getcEnrollments() { return cEnrollments; } public void setcEnrollments(Enrollment e) { cEnrollments.add(e); } public String toString() { String s="[course "+code+" "+description+" "+credits+"]"; for(Enrollment e:cEnrollments) { s+=" "+e.toString(); } return s; }

}

Here is the enrollment class

package com.example;

import java.util.Date;

public class Enrollment { private Student student; private Course course; private Date registration; public Enrollment(Student student, Course course, Date registration) { super(); this.student = student; this.course = course; this.registration = registration; } public Student getStudent() { return student; } public Course getCourse() { return course; } public Date getRegistration() { return registration; } public String toString() { return "[enrollment "+student.getCode()+" "+ course.getCode()+" "+registration+"]"; }

}

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

More Books

Students also viewed these Databases questions