Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://www.cs.iastate.edu/~cs227/assignments/preassignment1/pre1.pdf the assignment
- http://www.cs.iastate.edu/~cs227/assignments/preassignment1/speccheck_pre1.jar link to the specchecker
- package pre1;
- public class CrapsGame {
- public static final int READY = 1;
- public static final int COME_OUT = 2;
- public static final int POINT = 3;
- public static final int WIN = 4;
- public static final int LOSE = 5;
- private int state;
- private int point;
- public CrapsGame(){
- state = 1;
- point = 0;
- }
- public void betsPlaced(){
- if(state == 1)
- state = 2;
- }
- public void betsSettled(){
- if(state == 4 || state == 5){
- state = 1;
- }
- }
- public void diceRolled(int value){
- if(state == 2){
- if(value == 2 || value == 3 || value == 12){
- state = 5;
- }
- if(value == 7 || value == 11){
- state = 4;
- }
- if(value == 4 || value == 5 || value == 6 ||
- value == 8 || value == 9 || value == 10){
- state = 3;
- point = value;
- }
- }
- else{
- if(state == 3){
- if(value == 7){
- state = 5;
- }
- if(value == point){
- state = 4;
- }
- }
- }
- }
- public int getState(){
- return state;
- }
- public int getPoint(){
- return point;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement