(****** * * Module Graphs is made to hold the graphing stuff. * *) module Graphs from gradeditems import Gradebook; from NewClass import StatsBar; export all; object Histogram is components: HistoSegment*; description: (* The histogram object holds segments of the histogram, each representing a different grade. *); end Histogram; object HistoSegment is components: HistoRow* and Grade and Color; description: (* The HistoSegment object contains a collection of rows which display a more detailed view of where students stand in the class. It also contains the grade of the segment and the color that represents that grade. *); end HistoSegment; object HistoRow is components: Score and NumOfStudents; description: (* The HistoRow keeps track of how many students have a certain score, and the score that they all got. This is what is displayed as a row of datapoints on the histogram. *); end HistoRow; object PieChart is components: PieSegment* and Mean and Median and StdDev and HighScore and LowScore; description: (* The pie chart is a collection of pie segments which represent different grades. It also has a wide range of statistics. *); end PieChart; object PieSegment is components: Grade and Percentage and Color; description: (* Each segment represents a different grade, and has its own corresponding color. It also has a certain percentage of the whole pie chart which will decide how large a slice it is. *); end PieSegment; operation sumScores is inputs: g: GradeBook, s: Score; outputs: i: Integer; preconditions: #g.totalScore != 0; postconditions: i <= #g; description: (* Counts how many students are within a certain grade range. *); end sumScores; operation displayPie is inputs: g: GradeBook, a: Integer, b: Integer, c: Integer, d: Integer, f: Integer; outputs: pie: PieChart; preconditions: (#g.totalScore != 0); (* If a,b,c,d or f is nil, then default to standard grading scale *) postconditions: (sumScores(g,a) + sumScores(g,b) + sumScores(g,c) + sumScores(g,d) + sumScores(g,f)) < #g.totalScore; description: (* Displays a pie chart. *); end displayPie; operation displayHisto is inputs: g: GradeBook, a: Integer, b: Integer, c: Integer, d: Integer, f: Integer; outputs: histo: Histogram; preconditions: (g#.totalScore != 0); (* If a,b,c,d or f is nil, then default to standard grading scale; *) postconditions: (sumScores(g,a) + sumScores(g,b) + sumScores(g,c) + sumScores(g,d) + sumScores(g,f)) < #g.totalScore; description: (* Displays a histogram. *); end displayHisto; operation dragLinePie is inputs: gradebook: GradeBook, orig_low: Integer , orig_high: Integer, origPie: PieChart; outputs: new_low: Integer, new_high: Integer, newPie: PieChart, gradebook': GradeBook; precondition: orig_low < orig_high; postcondition: new_low <= new_high; description: This will simply call the displyPie operation with the new grade ranges. end dragLinePie; operation dragLineHisto is inputs: gradebook: GradeBook, orig_low: Integer, orig_high: Integer, origHisto: Histogram; outputs: newHisto: Histogram, new_low: Integer, new_high: Integer, gradebook':GradeBook; precondition: orig_low < orig_high; postcondition: new_low <= new_high; description: This will call the displayHisto operation with the new grade ranges. end dragLineHisto; object Color is components: s: string; description: (* The name of the color to be displayed on the graphs.*); end Color; object Percentage is components: r: real; description: (* The percentage of students with the same grade. *); end Percentage; object Grade is components: s: string; description: (* A possible grade. *); end Grade; object NumOfStudents is components: i: integer; description: (* Number of students *); end NumOfStudents; object Score is components: r: real; description: (* The raw score of a student. *); end Score; (* These need to be added to another file and imported to here. object Mean is real; object Median is real; object StdDev is real; object HighScore is real; object LowScore is real; *) end Graphs;