Skip to content

Commit

Permalink
Merge pull request #13 from similato87/dev
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
similato87 authored Mar 22, 2023
2 parents 21f9942 + 27c76b0 commit ec4d3be
Show file tree
Hide file tree
Showing 57 changed files with 884 additions and 164 deletions.
6 changes: 6 additions & 0 deletions .classpath
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>
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/.idea/
.vs/*
/bin/
./out/
.project
.classpath
/doc/
/obj/
/data/
28 changes: 28 additions & 0 deletions .project
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>
30 changes: 30 additions & 0 deletions README.md
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 removed data/README.md
Empty file.
1 change: 0 additions & 1 deletion doc/demo.txt

This file was deleted.

32 changes: 32 additions & 0 deletions main/src/Controller/CourseIterator.java
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;
}
}
21 changes: 21 additions & 0 deletions main/src/Controller/DepartmentFactory.java
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);
}
}
}
19 changes: 0 additions & 19 deletions main/src/Controller/Enrol.java

This file was deleted.

58 changes: 58 additions & 0 deletions main/src/Controller/EnrollmentBuilder.java
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;
}
}
36 changes: 36 additions & 0 deletions main/src/Controller/EnrollmentProxy.java
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);

}


}
20 changes: 0 additions & 20 deletions main/src/Controller/Init.java

This file was deleted.

8 changes: 8 additions & 0 deletions main/src/Controller/Iterator.java
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();
}

91 changes: 91 additions & 0 deletions main/src/Controller/RecordAdapter.java
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;}
}
Loading

0 comments on commit ec4d3be

Please sign in to comment.