Skip to content

Commit

Permalink
static enum refs added
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidSelf committed Aug 18, 2017
1 parent 41808e9 commit cbda167
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
24 changes: 24 additions & 0 deletions src/mainapp/controller/Refs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package mainapp.controller;

public class Refs {

public static class Click{

public static final int FIELD_ONE = 1;
public static final int FIELD_TWO = 2;
public static final int FIELD_THREE = 3;
public static final int FIELD_FOUR = 4;
public static final int FIELD_FIVE = 5;
public static final int FIELD_SIX = 6;
public static final int FIELD_SEVEN = 7;
public static final int FIELD_EIGHT = 8;
public static final int FIELD_NINE = 9;
}

public static class State{

public static final int WIN = 1;
public static final int DRAW = 2;

}
}
24 changes: 13 additions & 11 deletions src/mainapp/controller/SqlController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mainapp.model.Figures;
import mainapp.model.GameStatus;
import mainapp.SqlPsvm;
import mainapp.controller.Refs.*;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -124,53 +125,53 @@ private void setImjes(char figure, int event) throws SQLException {


switch (event) {
case 1:
case Click.FIELD_ONE:

img1.setImage(randPics(figure));
update(figure, event);
break;
case 2:
case Click.FIELD_TWO:

img2.setImage(randPics(figure));
update(figure, event);

break;
case 3:
case Click.FIELD_THREE:
img3.setImage(randPics(figure));
update(figure, event);

break;
case 4:
case Click.FIELD_FOUR:

img4.setImage(randPics(figure));
update(figure, event);

break;
case 5:
case Click.FIELD_FIVE:

img5.setImage(randPics(figure));
update(figure, event);

break;
case 6:
case Click.FIELD_SIX:

img6.setImage(randPics(figure));
update(figure, event);

break;
case 7:
case Click.FIELD_SEVEN:

img7.setImage(randPics(figure));
update(figure, event);

break;
case 8:
case Click.FIELD_EIGHT:

img8.setImage(randPics(figure));
update(figure, event);

break;
case 9:
case Click.FIELD_NINE:

img9.setImage(randPics(figure));
update(figure, event);
Expand Down Expand Up @@ -318,14 +319,15 @@ public void isEnd() throws Exception {


switch (key) {
case 1:

case State.WIN:
isend = true;
addRedline(fxGameStatus.getVec(), sqlPsvm.getGridRoot().getChildren());
sqlPsvm.andWinnerIs(fxGameStatus.getWhosTurn());
System.exit(1);
break;

case 2:
case State.DRAW:
isend = true;
sqlPsvm.draw();
System.exit(1);
Expand Down

0 comments on commit cbda167

Please sign in to comment.