// File: Statistician.java
// This is an assignment for students to complete after reading Chapter 2 of
// "Data Structures and Other Objects Using Java" by Michael Main.
// Check with your instructor to see whether you should put this class in
// a package. At the moment, it is declared as part of edu.colorado.homework:
package edu.colorado.homework;
/******************************************************************************
* This class is a homework assignment;
* A Statistician
keeps track of statistics about a sequence of
* double numbers.
*
* Note:
* This file contains only blank implementations ("stubs")
* because this is a Programming Project for my students.
*
* Outline of Java Source Code for this class:
*
* http://www.cs.colorado.edu/~main/edu/colorado/homework/Statistician.java
*
*
* @version Feb 10, 2016
******************************************************************************/
public class Statistician
{
/**
* Initialize a new Statistician.
* Postcondition:
* This Statistician is newly initialized and has not yet been given any
* numbers.
**/
public Statistician( )
{
// Student implementation.
}
/**
* Add the numbers of another Statistician to this Statistician.
* @param addend
* a Statistician whose numbers will be added to this Statistician
* Precondition:
* The parameter, addend
, is not null.
* Postcondition:
* The numbers from addend
have been added to this
* Statistician. After the operation, this Statistician acts as if
* if was given all of its numbers and also given all of the numbers
* from the addend.
* @exception NullPointerException
* Indicates that addend
is null.
**/
public void addAll(Statistician addend)
{
// Student implementation.
}
/**
* Clear this Statistician.
* Postcondition:
* This Statistician is reinitialized as if it has never been given any
* numbers.
**/
public void clear( )
{
// Student implementation.
}
/**
* Compare this Statistician
to another object for equality.
* @param obj
* an object with which this Statistician
will be compared
* @return
* 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
.
**/
public boolean equals(Object obj)
{
// The student's code will replace this return statement:
return false;
}
/**
* Determine how many numbers have been given to this Statistician.
* @return
* 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.
**/
public int length( )
{
// The student's code will replace this return statement:
return 0;
}
/**
* Determine the largest number that has been given
* to this Statistician.
* @return
* 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
.
**/
public double maximum( )
{
// The student's code will replace this return statement:
return 0;
}
/**
* Determine the arithmetic average of all the numbers that have been given
* to this Statistician.
* @return
* 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
.
**/
public double mean( )
{
// The student's code will replace this return statement:
return 0;
}
/**
* Determine the smallest number that has been given
* to this Statistician.
* @return
* 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
.
**/
public double minimum( )
{
// The student's code will replace this return statement:
return 0;
}
/**
* Give a new number to this Statistician.
* @param 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.
**/
public void next(double number)
{
// Student implementation.
}
/**
* Determine the sum of all the numbers that have been given to this
* Statistician.
* @return
* 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
.
**/
public double sum( )
{
// The student's code will replace this return statement:
return 0;
}
/**
* Create a new Statistician that behaves as if it was given all the
* numbers from two other bags.
* @param s1
* the first of two Statisticians
* @param s2
* the second of two Statisticians
* Precondition:
* Neither s1 nor s2 is null.
* @return
* a new Statistician that acts as if it was given all the numbers from
* s1 and s2.
* @exception NullPointerException
* Indicates that one of the arguments is null.
**/
public static Statistician union(Statistician s1, Statistician s2)
{
// The student's code will replace this return statement:
return null;
}
}