Class Guess

java.lang.Object
   |
   +----Guess

public class Guess
extends Object
This class defines guesses of arbitrary length as arrays of integers, along with some useful functions. Zero represents a blank (unfilled) element.

This class was originally an extension of Vector for greater flexibility, but the type-checking and protection available by doing so seemed very poor.


Method Index

 o equals(Guess)
Shows if two guesses contain the same elements.
 o equals(Guess, int)
Shows if two guesses have equal elements at a particular position.
 o equals(Guess, int, int)
Shows if two guesses have equal elements at particular positions.
 o indexOf(int, int)
Returns first position greater than the input value at which a given value appears.
 o isFull()
Show if all elements have been filled.
 o makeRandom(int, int)
Fill guess with random integer values within 1 to an upper limit.
 o setValue(int, int)
Set the value of an element.
 o toString(int)
Used to print out one element instead of the entire array.

Methods

 o toString
 public String toString(int position)
Used to print out one element instead of the entire array.

 o setValue
 public void setValue(int position,
                      int num)
Set the value of an element.

Parameters:
position - element index
num - new value
 o equals
 public boolean equals(Guess correct)
Shows if two guesses contain the same elements.

 o equals
 public boolean equals(Guess attempt,
                       int position)
Shows if two guesses have equal elements at a particular position.

Parameters:
attempt - the guess to be compared
position - position at which comparison is done
 o equals
 public boolean equals(Guess attempt,
                       int position1,
                       int position2)
Shows if two guesses have equal elements at particular positions.

Parameters:
attempt - the guess to be compared
position1 - position of calling object at which comparison is done
position2 - position of attempt at which comparison is done
 o makeRandom
 public void makeRandom(int range,
                        int maxDuplication)
Fill guess with random integer values within 1 to an upper limit.

Parameters:
range - upper limit of generated value
maxDuplication - maximum number of elements with the same value permitted
 o isFull
 public boolean isFull()
Show if all elements have been filled.

 o indexOf
 public int indexOf(int value,
                    int start)
Returns first position greater than the input value at which a given value appears. If it is not found, -1 is returned.

Parameters:
value - value to be found
start - index to start looking at