From 6f83e83573a3d666cdd0cee0441add8efb011061 Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 10:05:11 -0700 Subject: [PATCH 1/8] new file: src/main/java/Class.java new file: src/main/java/Course.java new file: src/main/java/GradebookCategory.java new file: src/main/java/GradebookItem.java new file: src/main/java/GradingScheme.java new file: src/main/java/Section.java new file: src/main/java/Student.java --- src/main/java/Class.java | 51 +++++++++++++++++ src/main/java/Course.java | 61 +++++++++++++++++++++ src/main/java/GradebookCategory.java | 27 +++++++++ src/main/java/GradebookItem.java | 37 +++++++++++++ src/main/java/GradingScheme.java | 32 +++++++++++ src/main/java/Section.java | 68 +++++++++++++++++++++++ src/main/java/Student.java | 82 ++++++++++++++++++++++++++++ 7 files changed, 358 insertions(+) create mode 100644 src/main/java/Class.java create mode 100644 src/main/java/Course.java create mode 100644 src/main/java/GradebookCategory.java create mode 100644 src/main/java/GradebookItem.java create mode 100644 src/main/java/GradingScheme.java create mode 100644 src/main/java/Section.java create mode 100644 src/main/java/Student.java diff --git a/src/main/java/Class.java b/src/main/java/Class.java new file mode 100644 index 0000000..09977f0 --- /dev/null +++ b/src/main/java/Class.java @@ -0,0 +1,51 @@ +package main.java; + +import java.util.ArrayList; + +public class Class { + private Course course; + public Course getCourse() { + return course; + } + + public void setCourse(Course course) { + this.course = course; + } + + public ArrayList
getSections() { + return sections; + } + + public void setSections(ArrayList
sections) { + this.sections = sections; + } + + private ArrayList
sections; + private double aveGrade; + private String aveLetterGrade; + + public Class(ArrayList
sections, Course course) { + this.sections = sections; + this.course = course; + } + public void calculate() { + int count = 1; + for (Section g : this.sections) { + g.calculate(); + this.aveGrade += g.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"; + } + } +} diff --git a/src/main/java/Course.java b/src/main/java/Course.java new file mode 100644 index 0000000..1f75c77 --- /dev/null +++ b/src/main/java/Course.java @@ -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 preRequizites; + private ArrayList classes; + + public Course(String subject, int courseNumber, String name, + ArrayList preRequizites,ArrayList classes) { + this.subject = subject; + this.courseNumber = courseNumber; + this.name = name; + this.preRequizites = preRequizites; + this.classes =classes; + } + + public ArrayList getClasses() { + return classes; + } + + public void setClasses(ArrayList 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 getPreRequizites() { + return preRequizites; + } + + public void setPreRequizites(ArrayList preRequizites) { + this.preRequizites = preRequizites; + } + +} diff --git a/src/main/java/GradebookCategory.java b/src/main/java/GradebookCategory.java new file mode 100644 index 0000000..4a4f353 --- /dev/null +++ b/src/main/java/GradebookCategory.java @@ -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; + } +} diff --git a/src/main/java/GradebookItem.java b/src/main/java/GradebookItem.java new file mode 100644 index 0000000..5c9681d --- /dev/null +++ b/src/main/java/GradebookItem.java @@ -0,0 +1,37 @@ +package main.java; + +public class GradebookItem { + private String name; + private GradebookCategory gradeCategory; + private double 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 GradebookItem(String name, GradebookCategory gradeCategory,double score) { + this.name = name; + this.gradeCategory = gradeCategory; + this.score=score; + } + + public double getScore() { + return score; + } + + public void setScore(double score) { + this.score = score; + } + +} diff --git a/src/main/java/GradingScheme.java b/src/main/java/GradingScheme.java new file mode 100644 index 0000000..a75fe70 --- /dev/null +++ b/src/main/java/GradingScheme.java @@ -0,0 +1,32 @@ +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; + } + +} diff --git a/src/main/java/Section.java b/src/main/java/Section.java new file mode 100644 index 0000000..a9c0d9b --- /dev/null +++ b/src/main/java/Section.java @@ -0,0 +1,68 @@ +package main.java; + +import java.util.ArrayList; + +public class Section { + private ArrayList students; + private Class theClass; + private double aveGrade; + private String aveLetterGrade; + + public Section(Class theClass, ArrayList 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 getStudents() { + return students; + } + + public void setStudents(ArrayList 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"; + } + } +} diff --git a/src/main/java/Student.java b/src/main/java/Student.java new file mode 100644 index 0000000..ab0e98d --- /dev/null +++ b/src/main/java/Student.java @@ -0,0 +1,82 @@ +package main.java; + +import java.util.ArrayList; + +public class Student { + private String name; + private ArrayList
sections; + private ArrayList gradeItems; + private double grade; + private String letterGrade; + private GradingScheme gradeScheme; + + public Student(String name, ArrayList
sections, + ArrayList gradeItems, GradingScheme gradeScheme) { + this.name = name; + this.sections = sections; + this.gradeItems = gradeItems; + this.gradeScheme = gradeScheme; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ArrayList
getSections() { + return sections; + } + + public void setSections(ArrayList
sections) { + this.sections = sections; + } + + public ArrayList getGradeItems() { + return gradeItems; + } + + public void setGradeItems(ArrayList gradeItems) { + this.gradeItems = gradeItems; + } + + public void calculate() { + + for (GradebookItem g : this.gradeItems) { + this.grade += g.getScore() * g.getGradeCategory().getWeight() / 100; + } + this.grade += this.gradeScheme.getCurve(); + if(this.gradeScheme.isRoundUp()){ + this.grade = Math.ceil(this.grade); + } + if (this.grade < 60) { + this.letterGrade = "F"; + } else if (this.grade < 70) { + this.letterGrade = "D"; + } else if (this.grade < 80) { + this.letterGrade = "C"; + } else if (this.grade < 90) { + this.letterGrade = "B"; + } else { + this.letterGrade = "A"; + } + } + + public double getGrade() { + return grade; + } + + public void setGrade(double grade) { + this.grade = grade; + } + + public String getLetterGrade() { + return letterGrade; + } + + public void setLetterGrade(String letterGrade) { + this.letterGrade = letterGrade; + } +} From 5e5401cc22ba0ca1d6f558ed1cf241887274d69e Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 20:49:42 -0700 Subject: [PATCH 2/8] Update Class.java --- src/main/java/Class.java | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/Class.java b/src/main/java/Class.java index 09977f0..7fbc378 100644 --- a/src/main/java/Class.java +++ b/src/main/java/Class.java @@ -4,10 +4,23 @@ public class Class { private Course course; + private ArrayList
sections; + private double aveGrade; + private String aveLetterGrade; + + public Class(ArrayList
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; } @@ -20,19 +33,11 @@ public void setSections(ArrayList
sections) { this.sections = sections; } - private ArrayList
sections; - private double aveGrade; - private String aveLetterGrade; - - public Class(ArrayList
sections, Course course) { - this.sections = sections; - this.course = course; - } public void calculate() { int count = 1; - for (Section g : this.sections) { - g.calculate(); - this.aveGrade += g.getAveGrade(); + for (Section section : this.sections) { + section.calculate(); + this.aveGrade += section.getAveGrade(); count++; } this.aveGrade = this.aveGrade / count; From 272a3f1687e062b39298ab30940628bab449454e Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 20:50:01 -0700 Subject: [PATCH 3/8] Update Course.java --- src/main/java/Course.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/Course.java b/src/main/java/Course.java index 1f75c77..048515d 100644 --- a/src/main/java/Course.java +++ b/src/main/java/Course.java @@ -10,12 +10,12 @@ public class Course { private ArrayList classes; public Course(String subject, int courseNumber, String name, - ArrayList preRequizites,ArrayList classes) { + ArrayList preRequizites, ArrayList classes) { this.subject = subject; this.courseNumber = courseNumber; this.name = name; this.preRequizites = preRequizites; - this.classes =classes; + this.classes = classes; } public ArrayList getClasses() { From 6256fa3d5708fee5fbf7467e50094bd175b26959 Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 20:50:59 -0700 Subject: [PATCH 4/8] Update GradebookItem.java --- src/main/java/GradebookItem.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/GradebookItem.java b/src/main/java/GradebookItem.java index 5c9681d..68f1d02 100644 --- a/src/main/java/GradebookItem.java +++ b/src/main/java/GradebookItem.java @@ -4,6 +4,14 @@ 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; } @@ -20,12 +28,6 @@ public void setGradeCategory(GradebookCategory gradeCategory) { this.gradeCategory = gradeCategory; } - public GradebookItem(String name, GradebookCategory gradeCategory,double score) { - this.name = name; - this.gradeCategory = gradeCategory; - this.score=score; - } - public double getScore() { return score; } From a32791e08594cac9608cf2d7a0a346270c61948c Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 20:51:15 -0700 Subject: [PATCH 5/8] Update GradingScheme.java --- src/main/java/GradingScheme.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/GradingScheme.java b/src/main/java/GradingScheme.java index a75fe70..076cc0a 100644 --- a/src/main/java/GradingScheme.java +++ b/src/main/java/GradingScheme.java @@ -2,12 +2,11 @@ public class GradingScheme { private double curve; - + private boolean roundUp; public GradingScheme(double curve, boolean roundUp) { this.curve = curve; - this.roundUp = roundUp; } @@ -19,8 +18,6 @@ public void setCurve(double curve) { this.curve = curve; } - - public boolean isRoundUp() { return roundUp; } From ad57aafc68e0e88c1dc0300d859c4851f8c61578 Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 20:51:58 -0700 Subject: [PATCH 6/8] Update Student.java --- src/main/java/Student.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Student.java b/src/main/java/Student.java index ab0e98d..c3eb632 100644 --- a/src/main/java/Student.java +++ b/src/main/java/Student.java @@ -48,7 +48,7 @@ public void calculate() { this.grade += g.getScore() * g.getGradeCategory().getWeight() / 100; } this.grade += this.gradeScheme.getCurve(); - if(this.gradeScheme.isRoundUp()){ + if (this.gradeScheme.isRoundUp()) { this.grade = Math.ceil(this.grade); } if (this.grade < 60) { From 6aa69ae9c263f4bb2629f6a09febc63da4aab51d Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 20:53:30 -0700 Subject: [PATCH 7/8] Create SectionTest.java --- src/main/java/SectionTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/SectionTest.java diff --git a/src/main/java/SectionTest.java b/src/main/java/SectionTest.java new file mode 100644 index 0000000..8dc6184 --- /dev/null +++ b/src/main/java/SectionTest.java @@ -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(), new ArrayList()); + Section testSection = new Section(new Class(new ArrayList
(), course), new ArrayList () ); + assert(testSection.getStudents().size() == 0); + assert(testSection.getClass().getName() != "OOD"); + assert(testSection.getTheClass().getCourse().getName() == "OOD"); + } + +} From 4c38840c853ec3d0f948b03b9d66239b796a1b55 Mon Sep 17 00:00:00 2001 From: theshop Date: Thu, 1 Aug 2013 20:53:58 -0700 Subject: [PATCH 8/8] Create CourseTest.java --- src/main/java/CourseTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/CourseTest.java diff --git a/src/main/java/CourseTest.java b/src/main/java/CourseTest.java new file mode 100644 index 0000000..447acc0 --- /dev/null +++ b/src/main/java/CourseTest.java @@ -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(), new ArrayList()); + assert(course.getCourseNumber() == 2340); + assert(course.getName() == "OOD"); + assert(course.getSubject() == "CS"); + } + +}