-
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.
Merge pull request #13 from similato87/dev
Main
- Loading branch information
Showing
57 changed files
with
884 additions
and
164 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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="src" path="main/src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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 +1,9 @@ | ||
/.idea/ | ||
.vs/* | ||
/bin/ | ||
./out/ | ||
.project | ||
.classpath | ||
/doc/ | ||
/obj/ | ||
/data/ |
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Academia-Planner</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
<filteredResources> | ||
<filter> | ||
<id>1678385537235</id> | ||
<name></name> | ||
<type>30</type> | ||
<matcher> | ||
<id>org.eclipse.core.resources.regexFilterMatcher</id> | ||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments> | ||
</matcher> | ||
</filter> | ||
</filteredResources> | ||
</projectDescription> |
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,3 +1,33 @@ | ||
# Academia-Planner | ||
The system we are going to build is a course registration system. | ||
## Software Patterns | ||
- **Singleton** | ||
Classes: Database | ||
- **Proxy** (enrollments) | ||
Classes: EnrollmentProxy | ||
- **Builder** (enrollments) | ||
Classes: EnrollmentBuilder | ||
- **Factory method** (department) | ||
Interface: Department, DepartmentFactory Classes: CSDepartment(Factory), SWEDepartment(Factory), ECEDepartment(Factory) | ||
- **Adaptor** (record, recordAdaptor) | ||
Classes: Record, RecordAdaptor | ||
- **Iterator** (students, courses) | ||
Interface: Iterator, Classes: StudentIterator, CourseIterator | ||
- **Composite** (enrollment, transcript) | ||
Interface: Registration, Classes: Transcript | ||
## Result | ||
Demo: Example to create a student's transcript | ||
``` | ||
CS1073 Java I A 16.0 | ||
Transcript of John Doe(ID:3333333) | ||
Java I 4 90.0 | ||
Java II 4 70.0 | ||
Software Design Patterns and Architecture 4 85.0 | ||
Average Percentage: 81.66666666666667 | ||
Student: John Doe(3333333), Business, Fredericton | ||
Course[code='CS1073', name='Java I'] | ||
Process finished with exit code 0 | ||
``` | ||
|
Empty file.
This file was deleted.
Oops, something went wrong.
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 Controller; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import Model.Course; | ||
public class CourseIterator implements Iterator<Course>{ | ||
private int currentPosition = 0; | ||
private HashSet<Course> courseSet; | ||
private ArrayList<Course> courseList; | ||
|
||
public CourseIterator(HashSet<Course> set) { | ||
courseSet = set; | ||
courseList = new ArrayList<>(courseSet); | ||
} | ||
|
||
public Course getNext(){ | ||
if(!hasNext()) { | ||
return null; | ||
} | ||
Course student = courseList.get(currentPosition); | ||
currentPosition++; | ||
return student; | ||
} | ||
|
||
public boolean hasNext() { | ||
return currentPosition < courseList.size(); | ||
} | ||
|
||
public void reset() { | ||
currentPosition = 0; | ||
} | ||
} |
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,21 @@ | ||
package Controller; | ||
|
||
import Model.CSDepartment; | ||
import Model.Department; | ||
import Model.ECEDepartment; | ||
import Model.SWEDepartment; | ||
|
||
public class DepartmentFactory { | ||
public static Department createDepartment(String departmentType) { | ||
if (departmentType.equalsIgnoreCase("CS")) { | ||
return new CSDepartment(); | ||
} else if (departmentType.equalsIgnoreCase("SWE")) { | ||
return new SWEDepartment(); | ||
} else if( departmentType.equalsIgnoreCase("ECE")){ | ||
return new ECEDepartment(); | ||
} | ||
else { | ||
throw new IllegalArgumentException("Invalid department type: " + departmentType); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
package Controller; | ||
|
||
import java.util.Date; | ||
|
||
import Model.Course; | ||
import Model.Enrollment; | ||
import Model.Student; | ||
public class EnrollmentBuilder{ | ||
private int id; | ||
private Student student; | ||
private Course course; | ||
private Date termStart; | ||
private Date termEnd; | ||
private double grade; | ||
private String status; | ||
private Enrollment e; | ||
public EnrollmentBuilder(){} | ||
|
||
public EnrollmentBuilder setId(int id){ | ||
this.id=id; | ||
return this; | ||
} | ||
|
||
public EnrollmentBuilder setStudent(Student student){ | ||
this.student=student; | ||
return this; | ||
} | ||
|
||
public EnrollmentBuilder setCourse(Course course){ | ||
this.course=course; | ||
return this; | ||
} | ||
|
||
public EnrollmentBuilder setTermStart(Date termStart){ | ||
this.termStart=termStart; | ||
return this; | ||
} | ||
|
||
public EnrollmentBuilder setTermEnd(Date termEnd){ | ||
this.termEnd=termEnd; | ||
return this; | ||
} | ||
|
||
public EnrollmentBuilder setGrade(double grade){ | ||
this.grade=grade; | ||
return this; | ||
} | ||
|
||
public EnrollmentBuilder setStatus(String status){ | ||
this.status=status; | ||
return this; | ||
} | ||
|
||
public Enrollment build(){ | ||
e = new Enrollment(id,student,course,termStart,termEnd,grade,status); | ||
return e; | ||
} | ||
} |
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,36 @@ | ||
package Controller; | ||
|
||
import Model.Enrollment; | ||
|
||
import java.util.Scanner; | ||
|
||
public class EnrollmentProxy extends Enrollment { | ||
private final String password; | ||
private Enrollment enrollment; | ||
|
||
public EnrollmentProxy(String password) { | ||
this.password = password; | ||
} | ||
|
||
private void authenticate(String input) { | ||
// Scanner scanner = new Scanner(System.in); | ||
// System.out.println("Please enter password:"); | ||
// String input = scanner.nextLine(); | ||
|
||
if (!input.equals(password)) { | ||
// scanner.close(); | ||
throw new SecurityException("Incorrect password"); | ||
} | ||
if (enrollment == null) { | ||
enrollment = new Enrollment(); | ||
} | ||
// scanner.close(); | ||
} | ||
public void editGrade(String inputPassword, Enrollment enrollment, Double newGrade) { | ||
authenticate(inputPassword); | ||
enrollment.setGrade(newGrade); | ||
|
||
} | ||
|
||
|
||
} |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
package Controller; | ||
|
||
public interface Iterator<T> { | ||
public T getNext(); | ||
public boolean hasNext(); | ||
public void reset(); | ||
} | ||
|
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,91 @@ | ||
package Controller; | ||
|
||
import Model.Course; | ||
import Model.Enrollment; | ||
import Model.Record; | ||
|
||
import java.util.HashMap; | ||
|
||
public class RecordAdapter implements Record { | ||
private Enrollment enrollment; | ||
private Course course; | ||
HashMap<String,Double> ptScheme; | ||
private int creditHours; | ||
|
||
private String letterGrade; | ||
private double points; | ||
|
||
private String status; | ||
|
||
public RecordAdapter(Enrollment enrollment) { | ||
this.enrollment=enrollment; | ||
this.course= enrollment.getCourse(); | ||
this.creditHours = course.getCreditHours(); | ||
ptScheme= new HashMap<String,Double>(); | ||
|
||
setPointScheme(); | ||
updateLG(); | ||
|
||
calculatePoints(); | ||
|
||
} | ||
|
||
private void setPointScheme() { | ||
ptScheme.put("A+", 4.3); | ||
ptScheme.put("A", 4.0); | ||
ptScheme.put("A-", 3.7); | ||
ptScheme.put("B+", 3.3); | ||
ptScheme.put("B", 3.0); | ||
ptScheme.put("B-", 2.7); | ||
ptScheme.put("C+", 2.3); | ||
ptScheme.put("C", 2.0); | ||
ptScheme.put("C-", 1.7); | ||
} | ||
|
||
private void updateLG() { | ||
status = enrollment.getStatus(); | ||
if (status == "WITHDRAWN") {letterGrade = "W";} | ||
if (status == "INPROGRESS") {letterGrade = "INP";} | ||
else { | ||
HashMap<Double, String> scheme = course.getScheme(); | ||
|
||
double grade=enrollment.getGrade(); | ||
for(double g: scheme.keySet()){ | ||
|
||
if(grade>=g){ | ||
|
||
letterGrade=scheme.get(grade); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void calculatePoints() { | ||
for(String g: ptScheme.keySet()){ | ||
if(letterGrade == g){ | ||
|
||
points=ptScheme.get(letterGrade)*creditHours; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public String getCode() {return course.getCode();} | ||
|
||
@Override | ||
public String getCourseName() {return course.getName();} | ||
|
||
|
||
@Override | ||
public String getLetterGrade() {return letterGrade;} | ||
|
||
@Override | ||
public double getCreditHrs() {return creditHours;} | ||
|
||
@Override | ||
public double getPoints() {return points;} | ||
} |
Oops, something went wrong.