-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameGoals.java
More file actions
61 lines (56 loc) · 1.37 KB
/
Copy pathGameGoals.java
File metadata and controls
61 lines (56 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Colin Kugler
// CSC161.101
// Semester Project
// Sticks card game
// This is a GameGoals class with the method testGoals()
// to test whether or not the player reached their goal to win
public class GameGoals {
// game goals class made up of 1D and 2D arrays, type string values and type integer values
int[] cardsUsed = new int[5];
int[] goalsMet = new int[5];
public boolean testGoals(int[][] goalToMeet, int[][] currentHand) {
boolean gameWon = false;
for (int x = 0; x < 5; x++){
for (int y = 0; y < 5; y++){
if (goalToMeet[x][0] == 0){
if (cardsUsed[y] != 1 && goalsMet[x] != 1){
if (currentHand[y][1] == goalToMeet[x][1]){
cardsUsed[y] = 1;
goalsMet[x] = 1;
break;
}
}
}
else if (goalToMeet[x][1] == 0){
if (cardsUsed[y] != 1 && goalsMet[x] != 1){
if (currentHand[y][0] == goalToMeet[x][0]){
cardsUsed[y] = 1;
goalsMet[x] = 1;
break;
}
}
}
else{
if (cardsUsed[y] != 1 && goalsMet[x] != 1){
if (currentHand[y][0] == goalToMeet[x][0] && currentHand[y][1] == goalToMeet[x][1]){
cardsUsed[y] = 1;
goalsMet[x] = 1;
break;
}
}
}
}
}
int c = 0;
for (int z = 0; z < 5; z++){
if (goalsMet[z] == 1){
c += 1;
}
System.out.println(c);;
}
if (c == 5){
gameWon = true;
}
return gameWon;
}
}