|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface BalanceSpecification
A balance has 2 pans - left and right - and a set of weights which can be in 1 of the 2 pans or unused on the table. The weight set cannot be changed after initialisation and weights can be moved between the table and the pans. Initially all weights should be on the table.
Method Summary | |
---|---|
void |
addLeft(int x)
Search for the specified weight on the table. |
void |
addRight(int x)
Search for the specified weight on the table. |
int |
maxNumberOfWeights()
|
int |
maxThatCanBeWeighed()
|
void |
moveAllToTable()
Move all weights in left and right pans to the table |
void |
removeLeft(int x)
Search for the specified weight in the left pan. |
void |
removeRight(int x)
Search for the specified weight in the right pan. |
void |
weigh(int x)
|
int |
weighing()
|
java.lang.String |
weightsInLeft()
|
java.lang.String |
weightsInRight()
|
Method Detail |
---|
void addLeft(int x)
x
- is the weight that we wish to movevoid addRight(int x)
x
- is the weight that we wish to moveint maxNumberOfWeights()
int maxThatCanBeWeighed()
void moveAllToTable()
void removeLeft(int x)
x
- is the weight that we wish to movevoid removeRight(int x)
x
- is the weight that we wish to movevoid 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.int weighing()
java.lang.String weightsInLeft()
java.lang.String weightsInRight()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |