|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectabstractions.Balance
public abstract class Balance
Constructor Summary | |
---|---|
Balance(int numberOfWeights)
|
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. |
java.lang.String |
toString()
|
int |
weighing()
|
java.lang.String |
weightsInLeft()
|
java.lang.String |
weightsInRight()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface abstractions.BalanceSpecification |
---|
weigh |
Constructor Detail |
---|
public Balance(int numberOfWeights) throws java.lang.IllegalArgumentException
numberOfWeights
- is the maximum number of weights that can be on the table or in the pans
java.lang.IllegalArgumentException
- if the numberOfWeights is not a positive integer;Method Detail |
---|
public void addLeft(int x)
BalanceSpecification
addLeft
in interface BalanceSpecification
x
- is the weight that we wish to movepublic void addRight(int x)
BalanceSpecification
addRight
in interface BalanceSpecification
x
- is the weight that we wish to movepublic int maxNumberOfWeights()
maxNumberOfWeights
in interface BalanceSpecification
public int maxThatCanBeWeighed()
maxThatCanBeWeighed
in interface BalanceSpecification
public void moveAllToTable()
BalanceSpecification
moveAllToTable
in interface BalanceSpecification
public void removeLeft(int x)
BalanceSpecification
removeLeft
in interface BalanceSpecification
x
- is the weight that we wish to movepublic void removeRight(int x)
BalanceSpecification
removeRight
in interface BalanceSpecification
x
- is the weight that we wish to movepublic java.lang.String toString()
toString
in class java.lang.Object
public int weighing()
weighing
in interface BalanceSpecification
public java.lang.String weightsInLeft()
weightsInLeft
in interface BalanceSpecification
public java.lang.String weightsInRight()
weightsInRight
in interface BalanceSpecification
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |