Class Statistician


public class Statistician extends Object
A Statistician keeps track of statistics about a sequence of double numbers.
Note:
 This file contains only blank implementations ("stubs") .
Outline of Java Source Code for this class:
http://www.southwestern.edu/~owensb/PC2/Labs/Statistician.java


Constructor Index

o Statistician()
Initialize a new Statistician.

Method Index

o clear()
Clear this Statistician.
o equals(Object)
Compare this Statistician to another object for equality.
o length()
Determine how many numbers have been given to this Statistician.
o maximum()
Determine the largest number that has been given to this Statistician.
o mean()
Determine the arithmetic average of all the numbers that have been given to this Statistician.
o minimum()
Determine the smallest number that has been given to this Statistician.
o next(double)
Give a new number to this Statistician.
o sum()
Determine the sum of all the numbers that have been given to this Statistician.
o addAtEnd (Statistician, Statistician)
Create a new Statistician that behaves as if it was given all the numbers from two other Statisticians.

Constructors

oStatistician
public Statistician()
Initialize a new Statistician.
Parameters:
- - none
Postcondition:
 This Statistician is newly initialized and has not yet been given any numbers.

Methods

oclear
public void clear()
Clear this Statistician.
Parameters:
- - none
Postcondition:
 This Statistician is reinitialized as if it has never been given any numbers.
oequals
public boolean equals(Object obj)
Compare this Statistician to another object for equality.
Parameters:
obj - an object with which this Statistician will be compared
Returns:
A return value of true indicates that obj refers to a Statistican object with the same length, sum, mean, minimum and maximum as this Statistician. Otherwise the return value is false.
Note:
 If obj is null or does not refer to a Statistician object, then the answer is false.
Overrides:
equals in class Object
olength
public int length()
Determine how many numbers have been given to this Statistician.
Parameters:
- - none
Returns:
the count of how many numbers have been given to this Statistician since it was initialized or reinitialized.
Note:
 Giving a Statistician more than Integer.MAX_VALUE numbers, will cause failure with an arithmetic overflow.
omaximum
public double maximum()
Determine the largest number that has been given to this Statistician.
Parameters:
- - none
Returns:
the largest number that has been given to this Statistician since it was initialized or reinitialized.
Note:
 If length() is zero, then the answer from this method is Double.NaN.
omean
public double mean()
Determine the arithmetic average of all the numbers that have been given to this Statistician.
Parameters:
- - none
Returns:
the arithmetic mean of all the number that have been given to this Statistician since it was initialized or reinitialized.
Note:
 If this Statistician has been given more than Integer.MAX_VALUE numbers, then this method fails because of arithmetic overflow. If length() is zero, then the answer from this method is Double.NaN. If sum() exceeds the bounds of double numbers, then the answer from this method may be Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY.
ominimum
public double minimum()
Determine the smallest number that has been given to this Statistician.
Parameters:
- - none
Returns:
the smallest number that has been given to this Statistician since it was initialized or reinitialized.
Note:
 If length() is zero, then the answer from this method is Double.NaN.
onext
public void next(double number)
Give a new number to this Statistician.
Parameters:
number - the new number that is being given the this Statistician
Postcondition:
 The specified number has been given to this Statistician and it will be included in any subsequent statistics.
osum
public double sum()
Determine the sum of all the numbers that have been given to this Statistician.
Parameters:
- - none
Returns:
the sum of all the number that have been given to this Statistician since it was initialized or reinitialized.
Note:
 If the sum exceeds the bounds of double numbers, then the answer from this method may be Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY.
oaddAtEnd
public static Statistician addAtEnd(Statistician s1,
                                 Statistician s2)
Create a new Statistician that behaves as if it was given all the numbers from two other Statisticians.
Parameters:
s1 - the first of two Statisticians
s2 - the second of two Statisticians
Precondition:
 Neither s1 nor s2 is null.
Returns:
a new Statistician that acts as if it was given all the numbers from s1 and s2.
Throws: NullPointerException
Indicates that one of the arguments is null.