-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f259ed
commit 21f9942
Showing
7 changed files
with
205 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package Controller; | ||
|
||
import Model.Course; | ||
import Model.Enrollment; | ||
import Model.Student; | ||
|
||
import java.util.HashSet; | ||
|
||
public class Enrol { | ||
|
||
public HashSet<Student> getStudentList(){ | ||
return null; | ||
} | ||
|
||
public Enrollment createEnrollment(Student student, Course course){ | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
package Model; | ||
|
||
public class Course { | ||
|
||
private String code; | ||
private String section; | ||
private int creditHours; | ||
private String name; | ||
private String description; | ||
private String courseType; | ||
//Techinically we could have a list of class times in some sort of structure but we might not wanna mess with that at this time. | ||
|
||
|
||
public Course(String name) { | ||
|
||
this.name = name; | ||
|
||
public Course(){ | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name; | ||
public Course(String code, String section, int creditHours, String name, String description, String courseType){ | ||
this.code=code; | ||
this.section=section; | ||
this.creditHours=creditHours; | ||
this.name=name; | ||
this.description=description; | ||
this.courseType=courseType; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
public String getCode(){ return code; } | ||
public void setCode(String code){ this.code=code; } | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
public String getSection(){ return section; } | ||
public void setSection(String section){ this.section=section; } | ||
|
||
Course course = (Course) o; | ||
public int getCreditHours(){ return creditHours; } | ||
public void setCreditHours(int creditHours){ this.creditHours=creditHours; } | ||
|
||
return getName().equals(course.getName()); | ||
} | ||
public String getName(){ return name; } | ||
public void setName(String name){ this.name=name; } | ||
|
||
@Override | ||
public int hashCode() { | ||
return getName().hashCode(); | ||
} | ||
public String getDescription(){ return description; } | ||
public void setDescription(String description){ this.description=description; } | ||
|
||
public void updateCourseName(String name) | ||
{ | ||
this.name = name; | ||
} | ||
} | ||
public String getCourseType(){ return courseType; } | ||
public void setCourseType(String courseType){ this.courseType=courseType;} | ||
|
||
//Equals method needed? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package Model; | ||
|
||
import java.util.*; | ||
public class Database{ | ||
private static Database instance; | ||
private HashMap<Integer,Student> students; | ||
private HashMap<String,Course> courses; | ||
//We could use this as a 'logging' feature or something. The history of the session's actions. | ||
private HashMap<Integer,Enrollment> enrollments; | ||
|
||
|
||
private Database(){ | ||
this.students=new HashMap<Integer,Student>(); | ||
} | ||
|
||
public static Database getDB(){ | ||
//No need to multithread so single access instance is okay. | ||
if(instance==null){ | ||
instance=new Database(); | ||
} | ||
return instance; | ||
} | ||
|
||
public Student getStudent(int id){ | ||
return students.get(id); | ||
} | ||
|
||
//Could possibly return students.values() for a collection of Students if we want to observe all students instead of the map directly | ||
public HashMap getStudentMap(){ | ||
return students; | ||
} | ||
|
||
//Same thing with courses. | ||
public HashMap getCourseMap(){ | ||
return courses; | ||
} | ||
|
||
public Course getCourse(String courseCode){ | ||
return courses.get(courseCode); | ||
} | ||
|
||
//Same with enrollments | ||
public HashMap getEnrollments(){ | ||
return enrollments; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package Model; | ||
|
||
import java.util.*; | ||
public class Enrollment{ | ||
private int id; | ||
private Student student; | ||
private Course course; | ||
private Date termStart; | ||
private Date termEnd; | ||
private double grade; | ||
//Take from a course grading scheme or a default grading? | ||
private String letterGrade; | ||
//Should probably be an enum PASSED,FAILED,WITHDRAWN,INPROGRESS | ||
private String status; | ||
|
||
public Enrollment(){ | ||
} | ||
|
||
public int getID(){ return id;} | ||
//Should probably not be modified | ||
public void setID(int id){ this.id=id; } | ||
|
||
public Student getStudent(){ return student; } | ||
//Should also probably not be modified | ||
public void setStudent(Student student){ this.student=student; } | ||
|
||
public Course getCourse(){ return course; } | ||
public void setCourse(Course course){ this.course=course; } | ||
|
||
//The following are good things we should allow people to update. Term dates grades and course status are all things that can change. | ||
public Date getTermStart(){ return termStart; } | ||
public void setTermStart(Date start){ this.termStart=start; } | ||
|
||
public Date getTermEnd(){ return termEnd; } | ||
public void setTermEnd(Date end){ this.termEnd=end; } | ||
|
||
|
||
public double getGrade(){ return grade; } | ||
public void setGrade(double grade){ this.grade=grade; } | ||
|
||
public String getLetterGrade(){ return letterGrade; } | ||
public void updateLetterGrade() { | ||
HashMap<Double,String> scheme = new HashMap<>(); | ||
scheme.put(95.0, "A+"); | ||
scheme.put(90.0, "A"); | ||
scheme.put(85.0, "A-"); | ||
scheme.put(80.0, "B+"); | ||
scheme.put(75.0, "B"); | ||
scheme.put(70.0, "B-"); | ||
scheme.put(65.0, "C+"); | ||
scheme.put(60.0, "C"); | ||
scheme.put(55.0, "C-"); | ||
scheme.put(50.0, "D"); | ||
scheme.put(0.0,"F"); | ||
double grade=this.grade; | ||
for(double g: scheme.keySet()){ | ||
if(grade>=g){ | ||
letterGrade=scheme.get(g); | ||
} | ||
} | ||
} | ||
|
||
public String getStatus(){ return status; } | ||
public void setStatus(String status){ this.status=status; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package Model; | ||
|
||
public class Student { | ||
private int studentID; | ||
private String name; | ||
private String campus; | ||
private String program; | ||
|
||
public Student(){ | ||
} | ||
|
||
public Student(int studentID, String name, String campus, String program){ | ||
this.studentID=studentID; | ||
this.name=name; | ||
this.campus=campus; | ||
this.program=program; | ||
} | ||
|
||
public int getStudentID(){ return studentID; } | ||
//Restricted functionality? Should be private probably since we're emulating this being a PK | ||
public void setStudentID(int id){ this.studentID=id; } | ||
|
||
public String getName(){ return name; } | ||
public void setName(String name){ this.name=name; } | ||
|
||
public String getCampus(){ return campus; } | ||
public void setCampus(String campus){ this.campus=campus; } | ||
|
||
public String getProgram(){ return program; } | ||
public void setProgram(String program){ this.program=program; } | ||
//Equals method needed? | ||
} |