Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Welcome dear expert,, I can't use the methods in bluej when I create the object of class, I don't know why can you check the

Welcome dear expert,, I can't use the methods in bluej when I create the object of class, I don't know why can you check the code because The problem is shown in the picture and I have not found a solution yet , just I want to use the methods like add course and remove etc. this is the codes of classes : import java.util.ArrayList;
class University {
private String name;
private String location;
private ArrayList faculties;
public University(String name, String location){
this.name = name;
this.location = location;
this.faculties = new ArrayList>();
}
public void addFaculty(Faculty faculty){
faculties.add(faculty);
}
public void removeFaculty(Faculty faculty){
faculties.remove(faculty);
}
}
class Faculty {
private String name;
private ArrayList courses;
private ArrayList students;
public Faculty(String name){
this.name = name;
this.courses = new ArrayList>();
this.students = new ArrayList>();
}
public void addCourse(Course course){
courses.add(course);
}
public void removeCourse(Course course){
courses.remove(course);
}
public void admitStudent(Student student){
students.add(student);
}
public void expelStudent(Student student){
students.remove(student);
}
}
class Course {
private String name;
private String code;
private ArrayList enrolledStudents;
public Course(String name, String code){
this.name = name;
this.code = code;
this.enrolledStudents = new ArrayList>();
}
public void enrollStudent(Student student){
enrolledStudents.add(student);
}
public void unenrollStudent(Student student){
enrolledStudents.remove(student);
}
}
class Student {
private String name;
private int ID;
private ArrayList enrolledCourses;
public Student(String name, int ID){
this.name = name;
this.ID = ID;
this.enrolledCourses = new ArrayList>();
}
}
image text in transcribed

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago