|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectabstractions.Balance
models.TernaryBalance
public class TernaryBalance
Constructor Summary | |
---|---|
TernaryBalance(int number)
|
Method Summary | |
---|---|
void |
weigh(int x)
In a ternary system we can weigh the required amount by placing weights in the left and right pans |
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 TernaryBalance(int number)
number
- is the number of weights to be used in the weighing pans.
All these weights will have binary integer values from 1 ... 3^(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 |