Skip to content

Commit 716c014

Browse files
committed
Changes to Game
1 parent 0728be4 commit 716c014

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/Game.java

+20-7
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,39 @@ public int numCards(){
3434
public void playRound(){
3535
if (d.hasNext() == true && t.numSets() == 0){
3636
for (int i = 0; i < 3; i++){
37-
if (d.hasNext() == false)
37+
if (d.hasNext()){
3838
t.add(d.getNext());
3939
}
40+
else{
4041
return;
42+
}
4143
}
44+
}
4245

43-
else if (d.hasNext() == true && t.numSets() != 0){
46+
if (d.hasNext() && t.numSets() != 0){
4447
for (int x = 0; x < t.numCards() - 2; x++){
4548
for (int y = x + 1; y < t.numCards() - 1; y++){
4649
for (int z = y + 1; z < t.numCards(); z++){
4750
if (t.getCard(x).isSet(t.getCard(y), t.getCard(z))){
4851
t.removeSet(t.getCard(x), t.getCard(y), t.getCard(z));
49-
return;
52+
53+
if (t.numCards() < 12 && d.hasNext()) {
54+
for (int o = 0; o < 3; o++) {
55+
if (d.hasNext()) {
56+
t.add(d.getNext());
57+
}
58+
else {
59+
return;
60+
}
61+
}
62+
}
63+
return;
5064
}
51-
}
5265
}
53-
}
54-
return;
5566
}
56-
}
67+
}
68+
}
69+
}
5770

5871
public boolean isGameOver(){
5972
if (d.hasNext() == false && t.numSets() == 0){

0 commit comments

Comments
 (0)