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

-
Statistician()
-
Initialize a new Statistician.

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

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

clear
public void clear()
-
Clear this Statistician.
-
Parameters:
-
- - none
-
Postcondition:
-
This Statistician is reinitialized as if it has never been given
any numbers.
equals
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
length
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.
maximum
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.
mean
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.
minimum
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.
next
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.
sum
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.
addAtEnd
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.