|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.Observable
scheduler.db.coursedb.CourseDB
public class CourseDB
The class representing the course database.
| Nested Class Summary | |
|---|---|
static class |
CourseDB.CourseDoesNotExistException
Course already exists exception thrown in the set methods. |
static class |
CourseDB.CourseExistsException
Course already exists exception thrown in the set methods. |
static class |
CourseDB.SectionsTuple
A tuple representing the number of sectons for the courses. |
| Field Summary | |
|---|---|
static java.lang.String |
courseFields
A constant representing the course fields for a courses SQL database. |
protected java.util.Collection<Course> |
data
A collection of courses. |
protected java.util.Collection<CourseDB.SectionsTuple> |
sectionsPerCourse
A collection of the sections per course. |
| Constructor Summary | |
|---|---|
CourseDB()
Construct the database and grab the information from the SQL database. |
|
| Method Summary | |
|---|---|
void |
addCourse(Course c)
Adds a given course to the course database. |
void |
addCourseTest(Course c)
Same as addCourse, but used for testing purposes. |
void |
changeSections(java.lang.String id,
int sections)
Changes the number of sections per course |
void |
changeSections(java.util.Vector<java.util.Vector> dataTable)
|
void |
editCourse(Course c)
Edits a given course which is already in the course database. |
void |
editCourseTest(Course c)
The same as editCourse but for testing purposes. |
Course |
getCourse(int number,
java.lang.String courseType)
Gets the course by courseNum |
java.util.Collection<Course> |
getData()
Returns the collection of courses |
java.util.Vector<java.lang.String> |
getLabNames()
A method to get all of the lab course names in the Course Database. |
java.util.Vector<Course> |
getLabs()
A method to get all of the lab courses in the Course Database. |
int |
getTotalSections()
Returns the total number of sections |
void |
removeCourse(Course c)
Removes a given, already-exiting course from the course database |
void |
removeCourseTest(Course c)
The same as removeCourse() but for testing purposes. |
void |
setData(java.util.Collection<Course> data)
Sets the data in the courseDB |
boolean |
validId(int id)
Checks if the id is three digits long |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String courseFields
protected java.util.Collection<Course> data
protected java.util.Collection<CourseDB.SectionsTuple> sectionsPerCourse
| Constructor Detail |
|---|
public CourseDB()
| Method Detail |
|---|
public void changeSections(java.util.Vector<java.util.Vector> dataTable)
public void changeSections(java.lang.String id,
int sections)
id - The id of the course. The id will have a L if it
is a lab.sections - The number of sections for the coursepublic java.util.Collection<Course> getData()
public void setData(java.util.Collection<Course> data)
data - The data to be set.
public Course getCourse(int number,
java.lang.String courseType)
pre:
//
// The course number is three digits long
//
(this.validId(number) )
&&
//
// The string is either "Lab" or "Lecture"
//
(courseType == "Lab" or courseType == "Lecture")
post:
//
// The returned course has the id of number and
// course type of courseType
//
(course.id == number and course.courseType == courseType)
number - The course number.courseType - A string representing the course type
public boolean validId(int id)
pre:
//
// The id is a number from 100 to 999
//
(id < 1000 && id > 99 )
post:
id - The id of the course
public void addCourseTest(Course c)
throws CourseDB.CourseExistsException
pre:
//
// The course c is valid course
//
(c != null && c.isValidCourse() )
&&
//
// The course is not in the database
//
(c not in courseDB.data)
post:
//
// Only c is added to the database
//
(forall (Courses course)
(course in courseDB'.data) iff
( (course == c) or
(course in courseDB.data)))
c - The Course to be added.
CourseDB.CourseExistsException
public void addCourse(Course c)
throws CourseDB.CourseExistsException
pre:
//
// The course c is valid course
//
(c != null && c.isValidCourse() )
&&
//
// The course is not in the database
//
(c not in courseDB.data)
post:
//
// Only c is added to the database
//
(forall (Courses course)
(course in courseDB'.data) iff
( (course == c) or
(course in courseDB.data)))
c - The Course to be added.
CourseDB.CourseExistsExceptionpublic java.util.Vector<Course> getLabs()
pre:
post:
//
// The return value contains only labs.
//
(forall (Courses course in returnValue)
(course.type == "lab")
public java.util.Vector<java.lang.String> getLabNames()
pre:
post:
//
// The return value contains only labs.
//
(forall (Course c)
if (course.type == "lab") {
c.name in returnVal
}
public int getTotalSections()
public void editCourseTest(Course c)
pre:
//
// The course c is valid course
//
(c != null && c.isValidCourse() )
&&
//
// The course c is already in the database
//
(c in courseDB.data )
post:
//
// No courses are added to the database
//
(courseDB.data.size() == courseDB.data.size() )
&&
//
// The database is the same as the earlier version except
// for the edited course.
//
(forall (Courses course)
(course in courseDB'.data) iff
( (course == c) or
(course in courseDB.data && course.id != c.id )))
c - The Course to be edited.public void editCourse(Course c)
pre:
//
// The course c is valid course
//
(c != null && c.isValidCourse() )
&&
//
// The course c is already in the database
//
(c in courseDB.data )
post:
//
// No courses are added to the database
//
(courseDB.data.size() == courseDB.data.size() )
&&
//
// The database is the same as the earlier version except
// for the edited course.
//
(forall (Courses course)
(course in courseDB'.data) iff
( (course == c) or
(course in courseDB.data && course.id != c.id )))
c - The Course to be edited.
public void removeCourseTest(Course c)
throws CourseDB.CourseDoesNotExistException
pre:
//
// The course c is valid course
//
(c != null && c.isValidCourse() )
&&
//
// The course c is already in the database
//
(c in courseDB.data )
post:
//
// The database size is one smaller
//
(courseDB.data.size() == courseDB`.data.size() - 1 )
&&
//
// The database is the same as the earlier version except
// for the removed course.
//
(forall (Courses course)
(course in courseDB'.data) iff
( (course != c)))
c - The Course to be edited.
CourseDB.CourseDoesNotExistException
public void removeCourse(Course c)
throws CourseDB.CourseDoesNotExistException
pre:
//
// The course c is valid course
//
(c != null && c.isValidCourse() )
&&
//
// The course c is already in the database
//
(c in courseDB.data )
post:
//
// The database size is one smaller
//
(courseDB.data.size() == courseDB`.data.size() - 1 )
&&
//
// The database is the same as the earlier version except
// for the removed course.
//
(forall (Courses course)
(course in courseDB'.data) iff
( (course != c)))
c - The Course to be edited.
CourseDB.CourseDoesNotExistException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||