(*

 * Author: Manuel Garcia
 * This file defines the objects and operations for a visualization.
 *)

object Visualization is 
	components: bar:BarHistogram and pie:PieChart and dot:DotHistogram and
		grd:GradeScale and Percentage and NumStudents;
	description: (*
		A Visualization is a Bar Histogram, or Pie Chart, or Dot
		Histogram.  It has a GradeScale component as well as a 
		number of students and percentage of students component
		so if you modify the visualization, it can update the
		visualization.
	*);
end Visualization;

object BarHistogram is
	components: cl:ClassList and sl:SegmentList and gd:GradeItemName;
	description: (*
		A classList is a list that holds class objects that store the 
		information of gradebooks. Segment is a list of segments
		that are in a histogram or pie chart.
	*);
end BarHistogram;

object PieChart is
	components: cl:ClassList and sl:SegmentList and gd:GradeItemName;
	description: (*
		A classList is a list that holds class objects that store the 
		information of gradebooks. Segment is a list of segments
		that are in a histogram or pie chart.
	*);
end PieChart;

object DotHistogram is
	components: cl:ClassList and sl:SegmentList and gd:GradeItemName;
	description: (*		A classList is a list that holds class objects that store the 
		information of gradebooks. Segment is a list of segments
		that are in a histogram or pie chart.
		A classList is a list that holds class objects that store the 
		information of gradebooks. Segment is a list of segments
		that are in a histogram or pie chart.
	*);
end DotHistogram;

object ClassList is 
        components: cs:Class*;
        description: (*
                A ClassList is a list of Class objects.
        *);
end ClassList;

object SegmentList is
        components: ss:Segment*;
        description: (*
                A SegmentList is a list of segments.
        *);
end SegmentList;

object Segment is
	components: SegmentName and Percentage and NumStudents and IndGrade;
	description: (*
		A segmentName is a string that holds the name of the segment.
		Percentage is an int that holds the percentage of the segment.
		NumStudents is an int that holds the number of students in that
		segment.  IndGrade is an individual grade that allows us to 
                access the color of that grade.
	*);
end Segment;

object SegmentName is string;
object Percentage is integer;
object NumStudents is integer;
object GradeItemName is string;

operation drawBarHistogram is
	description: (*
		Draws a bar histogram in a seperate window.
	*);
	inputs: vis: Visualization;
        outputs: vis': Visualization;

	precondition:
		(*
		 * The ClassList and SegmentList is not empty.
		 *)
		(vis.bar.cl != nil and vis.bar.sl != nil);

	postcondition:
		(*
		 * Displaying a graph does not change any data.
		 *);
		
end drawBarHistogram;

operation adjBarHistogram is
	description: (*
		Modifies a bar histogram in a seperate window.
	*);
	inputs: bar:BarHistogram and seg: Segment and grd: GradeScale;
	outputs: bar':BarHistogram;

	precondition:
		(*
		 * The ClassList and SegmentList is not empty.
		 *)
		((bar.cl != nil) and bar.sl != nil)

				and
		(*
		 * The segment is not nil
		 *)
		(seg != nil)

				and
		(*
		 * The Gradescale is not nil
		 *)
		(grd != nil);

	postcondition:
		(*
		 * A new bar histogram is outputted.
		 *);
		--forall(vis:Visualization)
		    --forall(bar:BarHistogram)
			--forall(cs:Class)
			    --forall(Student)
				--forall(studentTotal);
end adjBarHistogram;

operation drawPieChart is
	description: (*
		Draws a pie chart in a seperate window.
	*);
	inputs: pie: PieChart;
	outputs: pie': PieChart;

	precondition:
		(*
		 * The ClassList and SegmentList is not empty.
		 *)
		((pie.cl != nil) and pie.sl != nil);

	postcondition:
		(*
		 * A pie chart is outputted.
		 *);

end drawPieChart;

operation adjPieChart is
	description: (*
		Modifies a pie chart in a seperate window.
	*);
	inputs: pie:PieChart and seg: Segment and grd: GradeScale;
	outputs: pie':PieChart;

	precondition:
		(*
		 * The ClassList and SegmentList is not empty.
		 *)
		((pie.cl != nil) and pie.sl != nil)

				and
		(*
		 * The segment is not NULL
		 *)
		(seg != nil)

				and
		(*
		 * The Gradescale is not nil
		 *)
		(grd != nil);

	postcondition:
		(*
		 * A new pie chart is outputted.
		 *);
		--forall(vis:Visualization)
		   --forall(bar:BarHistogram)
			--forall(cs:Class)
			    --forall(Student)
				--forall(studentTotal);

end adjPieChart;

operation drawDotHistogram is
	description: (*
		Draws a dot histogram in a seperate window.
	*);
	inputs: dot: DotHistogram;
	outputs: dot': DotHistogram;

	precondition:
		(*
		 * The ClassList and SegmentList is not empty.
		 *)
		((dot.cl != nil) and dot.sl != nil);

	postcondition:
		(*
		 * A dot histogram is outputted.
		 *);

end drawDotHistogram;

operation adjDotHistogram is
	description: (*
		Modifies a dot histogram in a seperate window.
	*);
	inputs: dot:DotHistogram and seg: Segment and grd: GradeScale;
	outputs: dot':DotHistogram;

	precondition:
		(*
		 * The ClassList and SegmentList is not empty.
		 *)
		((dot.cl != nil) and dot.sl != nil)

				and
		(*
		 * The segment is not NULL
		 *)
		(seg != nil)

				and
		(*
		 * The Gradescale is not nil
		 *)
		(grd != nil);

	postcondition:
		(*
		 * A new dot histogram is outputted.
		 *);
		--forall(vis:Visualization)
		    --forall(bar:BarHistogram)
			--forall(cs:Class)
			    --forall(Student)
				--forall(studentTotal);
end adjDotHistogram;