📄 coursesection.java
字号:
package Entities;
import dslib.list.LinkedListUos;
/** Represents a section associated with a course. */
public class CourseSection
{
/** The course section number */
protected int secNumber;
/** The instructor for the section */
protected Instructor instructor;
/** The room the class was being offered */
protected String room;
/** The details of a course section */
protected SectionDetails sectionDetails;
/** A lists of registrations */
public LinkedListUos registrationList;
/** The number of student allowed in the section */
protected int numberEnrolled;
/** Make a new course section from the arguments */
public CourseSection(int num, SectionDetails secD)
{
secNumber = num;
sectionDetails = secD;
numberEnrolled = 0;
registrationList = new LinkedListUos();
}
/** Set the room where this course section is to take place */
public void setRoom(String r)
{
room = r;
}
/** Assign an instructor for this section */
public void setInstructor(Instructor newProf)
{
instructor = newProf;
instructor.addCourse(this);
}
/** Set the enrollment limit for this section */
public void setLimit(int newLimit)
{
if (newLimit <= 0)
{
System.out.println("setLimit -- Invalid limit. Aborting!!");
return ;
}
sectionDetails.setLimit(newLimit);
}
/** Add a course_reg object to the list. This
records a student being registered in this section */
public void addRegistration(CourseReg newRegis)
{
if (isFull())
{
System.out.println("addRegistration -- section is full. Aborting!!");
return ;
}
registrationList.insert(newRegis);
numberEnrolled++;
}
/** Decrease the number of students enrolled */
public void decrementEnrollment()
{
numberEnrolled--;
}
/** Is this section full? */
public boolean isFull()
{
return (numberEnrolled >= limit());
}
/** Return a string representation of the section */
public String toString()
{
String result = "\nSection Number : " + secNumber;
if (instructor != null)
result += "\nInstructor : " + instructor;
else
result += "\nNo instructor assigned yet";
if (room != null)
result += "\nRoom : " + room;
else
result += "\nNo room appointed yet";
result += "\nNumber enrolled : " + numberEnrolled;
result += "\nSection Details: ";
result += sectionDetails.toString();
return result;
}
/** Return the course section number */
public int secNumber()
{
return secNumber;
}
/** Return the instructor for the section */
public Instructor instructor()
{
return instructor;
}
/** Return the total number of student allowed in that class */
public int limit()
{
return sectionDetails.limit();
}
/** Return the room the class was being offered */
public String room()
{
return room;
}
/** Return tThe time the course is offered */
public String timeOffered()
{
return sectionDetails.timeOffered();
}
/** Return the days the course is offered */
public String daysOffered()
{
return sectionDetails.daysOffered();
}
/** Return the number of student allowed in the section */
public int numberEnrolled()
{
return numberEnrolled;
}
/** Return the trem the classes is offered */
public int term()
{
return sectionDetails.term();
}
} /* end of CourseSection */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -