Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new file: src/main/java/Class.java #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/main/java/Class.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package main.java;

import java.util.ArrayList;

public class Class {
private Course course;
private ArrayList<Section> sections;
private double aveGrade;
private String aveLetterGrade;

public Class(ArrayList<Section> sections, Course course) {
this.sections = sections;
this.course = course;
}

public Course getCourse() {
return course;
}

public String getAvgLetterGrade() {
return aveLetterGrade;
}

public void setCourse(Course course) {
this.course = course;
}

public ArrayList<Section> getSections() {
return sections;
}

public void setSections(ArrayList<Section> sections) {
this.sections = sections;
}

public void calculate() {
int count = 1;
for (Section section : this.sections) {
section.calculate();
this.aveGrade += section.getAveGrade();
count++;
}
this.aveGrade = this.aveGrade / count;
if (this.aveGrade < 60) {
this.aveLetterGrade = "F";
} else if (this.aveGrade < 70) {
this.aveLetterGrade = "D";
} else if (this.aveGrade < 80) {
this.aveLetterGrade = "C";
} else if (this.aveGrade < 90) {
this.aveLetterGrade = "B";
} else {
this.aveLetterGrade = "A";
}
}
}
61 changes: 61 additions & 0 deletions src/main/java/Course.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package main.java;

import java.util.ArrayList;

public class Course {
private String subject;
private int courseNumber;
private String name;
private ArrayList<Course> preRequizites;
private ArrayList<Class> classes;

public Course(String subject, int courseNumber, String name,
ArrayList<Course> preRequizites, ArrayList<Class> classes) {
this.subject = subject;
this.courseNumber = courseNumber;
this.name = name;
this.preRequizites = preRequizites;
this.classes = classes;
}

public ArrayList<Class> getClasses() {
return classes;
}

public void setClasses(ArrayList<Class> classes) {
this.classes = classes;
}

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject;
}

public int getCourseNumber() {
return courseNumber;
}

public void setCourseNumber(int courseNumber) {
this.courseNumber = courseNumber;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public ArrayList<Course> getPreRequizites() {
return preRequizites;
}

public void setPreRequizites(ArrayList<Course> preRequizites) {
this.preRequizites = preRequizites;
}

}
17 changes: 17 additions & 0 deletions src/main/java/CourseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main.java;

import java.util.ArrayList;

import org.junit.Test;

public class CourseTest {

@Test
public void test() {
Course course = new Course("CS", 2340, "OOD",new ArrayList<Course>(), new ArrayList<Class>());
assert(course.getCourseNumber() == 2340);
assert(course.getName() == "OOD");
assert(course.getSubject() == "CS");
}

}
27 changes: 27 additions & 0 deletions src/main/java/GradebookCategory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main.java;

public class GradebookCategory {
private String name;
private double weight;

public GradebookCategory(String name, double weight) {
this.name = name;
this.weight = weight;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public double getWeight() {
return weight;
}

public void setWeight(double weight) {
this.weight = weight;
}
}
39 changes: 39 additions & 0 deletions src/main/java/GradebookItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main.java;

public class GradebookItem {
private String name;
private GradebookCategory gradeCategory;
private double score;

public GradebookItem(String name, GradebookCategory gradeCategory,
double score) {
this.name = name;
this.gradeCategory = gradeCategory;
this.score = score;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public GradebookCategory getGradeCategory() {
return gradeCategory;
}

public void setGradeCategory(GradebookCategory gradeCategory) {
this.gradeCategory = gradeCategory;
}

public double getScore() {
return score;
}

public void setScore(double score) {
this.score = score;
}

}
29 changes: 29 additions & 0 deletions src/main/java/GradingScheme.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main.java;

public class GradingScheme {
private double curve;

private boolean roundUp;

public GradingScheme(double curve, boolean roundUp) {
this.curve = curve;
this.roundUp = roundUp;
}

public double getCurve() {
return curve;
}

public void setCurve(double curve) {
this.curve = curve;
}

public boolean isRoundUp() {
return roundUp;
}

public void setRoundUp(boolean roundUp) {
this.roundUp = roundUp;
}

}
68 changes: 68 additions & 0 deletions src/main/java/Section.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package main.java;

import java.util.ArrayList;

public class Section {
private ArrayList<Student> students;
private Class theClass;
private double aveGrade;
private String aveLetterGrade;

public Section(Class theClass, ArrayList<Student> students) {
this.students = students;
this.theClass = theClass;
}

public double getAveGrade() {
return aveGrade;
}

public void setAveGrade(double aveGrade) {
this.aveGrade = aveGrade;
}

public String getAveLetterGrade() {
return aveLetterGrade;
}

public void setAveLetterGrade(String aveLetterGrade) {
this.aveLetterGrade = aveLetterGrade;
}

public ArrayList<Student> getStudents() {
return students;
}

public void setStudents(ArrayList<Student> students) {
this.students = students;
}

public Class getTheClass() {
return theClass;
}

public void setTheClass(Class theClass) {
this.theClass = theClass;
}

public void calculate() {
int count = 1;
for (Student g : this.students) {
g.calculate();
this.aveGrade += g.getGrade();
count++;
}
this.aveGrade = this.aveGrade / count;
if (this.aveGrade < 60) {
this.aveLetterGrade = "F";
} else if (this.aveGrade < 70) {
this.aveLetterGrade = "D";
} else if (this.aveGrade < 80) {
this.aveLetterGrade = "C";
} else if (this.aveGrade < 90) {
this.aveLetterGrade = "B";
} else {
this.aveLetterGrade = "A";
}
}
}
19 changes: 19 additions & 0 deletions src/main/java/SectionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main.java;

import java.util.ArrayList;

import org.junit.Test;


public class SectionTest {

@Test
public void test() {
Course course = new Course("CS", 2340, "OOD",new ArrayList<Course>(), new ArrayList<Class>());
Section testSection = new Section(new Class(new ArrayList<Section> (), course), new ArrayList<Student> () );
assert(testSection.getStudents().size() == 0);
assert(testSection.getClass().getName() != "OOD");
assert(testSection.getTheClass().getCourse().getName() == "OOD");
}

}
Loading