|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectp_models.Paddle
public class Paddle
Implements HasInvariant
, PaddleSpecification
A simple paddle model for use in a video game.
For teaching MVC design pattern.
Field Summary |
---|
Fields inherited from interface p_abstractions.PaddleSpecification |
---|
INVARIANT_OF_CLASS, MAXIMUM_position, MINIMUM_position |
Constructor Summary | |
---|---|
Paddle()
Tested by JUnit_Paddle.testDefaultConstructor() , which guarantees that the Paddle is
constructed in a safe state as specified by invariant() . |
|
Paddle(int pos)
Tested by JUnit_Paddle.testNonDefaultConstructor() , which guarantees that the Paddle is
constructed in a safe state as specified by invariant() . |
|
Paddle(java.util.Random rng)
Tested by RandomTest_Paddle , which guarantees that the Paddle is
constructed in a safe state as specified by invariant() . |
Method Summary | |
---|---|
void |
changeDirection()
Tested by JUnit_Paddle.testChangeDirection() , which guarantees that the Paddle
remains in a safe state as specified by invariant() . |
boolean |
equals(java.lang.Object thing)
|
int |
get_position()
|
boolean |
goingRight()
|
boolean |
invariant()
The position must be within the defined limit: PaddleSpecification.MINIMUM_position ... |
java.lang.String |
toString()
|
void |
updatePosition()
Tested by JUnit_Paddle.testUpdatePosition() , which guarantees that the Paddle remains
in a safe state as specified by invariant() . |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Paddle()
JUnit_Paddle.testDefaultConstructor()
, which guarantees that the Paddle is
constructed in a safe state as specified by invariant()
.MINIMUM_position
, and moving right
public Paddle(int pos)
JUnit_Paddle.testNonDefaultConstructor()
, which guarantees that the Paddle is
constructed in a safe state as specified by invariant()
.
pos
- specifies the initial horizontal position for the Paddle being constructed
public Paddle(java.util.Random rng)
RandomTest_Paddle
, which guarantees that the Paddle is
constructed in a safe state as specified by invariant()
.
rng
- is the random number generator to be used in the construction of a random Paddle:
Method Detail |
---|
public boolean invariant()
PaddleSpecification.MINIMUM_position
... PaddleSpecification.MAXIMUM_position
invariant
in interface HasInvariant
public int get_position()
get_position
in interface PaddleSpecification
MINIMUM_position
... MAXIMUM_position
public boolean goingRight()
goingRight
in interface PaddleSpecification
public void updatePosition()
JUnit_Paddle.testUpdatePosition()
, which guarantees that the Paddle remains
in a safe state as specified by invariant()
.
updatePosition
in interface PaddleSpecification
public void changeDirection()
JUnit_Paddle.testChangeDirection()
, which guarantees that the Paddle
remains in a safe state as specified by invariant()
.
changeDirection
in interface PaddleSpecification
public boolean equals(java.lang.Object thing)
equals
in interface PaddleSpecification
equals
in class java.lang.Object
thing
- is the input object to test for equalitypublic java.lang.String toString()
toString
in interface PaddleSpecification
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |