-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuess.java
More file actions
88 lines (80 loc) · 2.88 KB
/
Guess.java
File metadata and controls
88 lines (80 loc) · 2.88 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// CLASS: Guess
//
// Author: Huayi Chen
//
// REMARKS: a guess made by a player
//
//----------------------------------------
import java.util.ArrayList;
public class Guess {
private int index;
private int suspectIndex;
private int locationIndex;
private int weaponIndex;
private ArrayList<Card> suspect;
private ArrayList<Card> location;
private ArrayList<Card> weapon;
private boolean isAccusation;
public Guess(int index, int suspectIndex, int locationIndex, int weaponIndex, ArrayList<Card> suspect, ArrayList<Card> location, ArrayList<Card> weapon, boolean isAccusation){
this.index=index;
this.suspectIndex=suspectIndex;
this.locationIndex=locationIndex;
this.weaponIndex=weaponIndex;
this.suspect=suspect;
this.location=location;
this.weapon=weapon;
this.isAccusation=isAccusation;
}
//------------------------------------------------------
// Method: getIndex
// PURPOSE: return index
// PARAMETERS: non
// Returns: int
//------------------------------------------------------
public int getIndex() {
return index;
}
//------------------------------------------------------
// Method: isAccusation
// PURPOSE: return whether is an accusation
// PARAMETERS: non
// Returns: boolean
//------------------------------------------------------
public boolean isAccusation() {
return isAccusation;
}
//------------------------------------------------------
// Method: getChoice
// PURPOSE: return the guess selection list
// PARAMETERS: non
// Returns: ArrayList<Integer>
//------------------------------------------------------
public ArrayList<Integer> getChoice() {
ArrayList<Integer> choice=new ArrayList<>();
choice.add(suspectIndex);
choice.add(locationIndex);
choice.add(weaponIndex);
return choice;
}
//------------------------------------------------------
// Method: printResult
// PURPOSE: return current guess result
// PARAMETERS: non
// Returns: String
//------------------------------------------------------
public String printResult(){
String result;
if (isAccusation){
result=" (Player "+index+": Accusation: "
+suspect.get(suspectIndex).getName() +" in "
+location.get(locationIndex).getName()+" with the "
+weapon.get(weaponIndex).getName()+")";
}else {
result=" (Player "+index+": Suggestion: "
+suspect.get(suspectIndex).getName() +" in "
+location.get(locationIndex).getName()+" with the "
+weapon.get(weaponIndex).getName()+")";
}
return result;
}
}