|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectabstractions.Balance
models.BinaryBalance
public class BinaryBalance
Constructor Summary | |
---|---|
BinaryBalance(int number)
|
Method Summary | |
---|---|
void |
weigh(int x)
In a binary system we can weigh the required amount by placing weights in the left pan only |
Methods inherited from class abstractions.Balance |
---|
addLeft, addRight, maxNumberOfWeights, maxThatCanBeWeighed, moveAllToTable, removeLeft, removeRight, toString, weighing, weightsInLeft, weightsInRight |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BinaryBalance(int number) throws java.lang.IllegalArgumentException
number
- is the number of weights to be used in the weighing pans.
All these weights will have binary integer values from 1 ... 2^(number-1)
java.lang.IllegalArgumentException
- if:
Method Detail |
---|
public void weigh(int x)
x
- is the weight that we wish to weigh in the right pan. This method should
move the weights around in order to weigh this amount. If no exact solution is found then it
should find a solution as close as possible to the one required.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |