Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider a Course Class that consists of id , title, credit, tuition per credit, number of students that defines the number of students currently enrolled
Consider a Course Class that consists of id title, credit, tuition per credit, number of students
that defines the number of students currently enrolled in this course. It has the seat capacity that
determines the maximum number of students that are allowed in this course. The default capacity
has been set to but it is increased by increaseSeatCapacityint size method describe
below.
public class Course
private final static int DEFAULTCAPACITY ;
private String id;
private String title;
private int credit;
private int tuitionPerCredit;
private int numOfStudent;
private int seatCapacity;
public CourseString id String title, int credit, int
tuitionPerCredit
this.id id;
this.title title;
this.credit credit;
this.tuitionPerCredit tuitionPerCredit;
this.seatCapacity DEFAULTCAPACITY;
getter and setter methods for instance variables
public void increaseSeatCapacityint size
this.seatCapacity this.seatCapacity size;
public void increaseNumberOfStudent
numOfStudent;
public void decreaseNumberOfStudent
numOfStudent;
CurrentOfferedCourse class forms the pool of academic courses, the university offers. The
pool of courses is put in cList array which has a default capacity of but it could be increased
dynamically by doubling it if its capacity is exhausted.
Class: CurrentOfferedCourse
addCoursecourse : Course : void This method will take a Course object as a
parameter and will add it to the array of cList if the
number of courses is less than the array length. If
the capacity exceeded the length, the array pool is
doubled and the course is put there.
getCoursecourse : Course : Course This method returns a Course object if it is offered
in a semester otherwise returns null.
getCourseList : Course This method will return an array of Course,
containing all the offered courses in a semester.
public class CurrentOfferedCourse
private Course cList;
private int numberOfCourse;
private static CurrentOfferedCourse instance;
public CurrentOfferedCourse
cList new Course;
public static CurrentOfferedCourse getInstance
ifinstance null
instance new CurrentOfferedCourse;
return instance;
public int getNumberOfCourse
return numberOfCourse;
public void addCourseCourse course
Code for addCourse
public Course getCourseCourse course
public Course getCourseList
Question: Write down the code for addCouse, getCourse, getCourseList in script
with comments highlighting the necessity of the line in coding.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started