-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiplayer.java
More file actions
88 lines (68 loc) · 1.86 KB
/
Multiplayer.java
File metadata and controls
88 lines (68 loc) · 1.86 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
import java.util.Collections; // use collections methods such as frequency
import java.util.ArrayList; // for arraylist
public class Multiplayer
{
private ArrayList<Integer> rolls = new ArrayList<Integer>(5); // hold roll values for players
private int[] scoreBoard = new int[13]; // hold score for each category
private int score; // hold total score
public Multiplayer()
{
for (int i = 0; i<13; i++)
scoreBoard[i]=-1;// intialize scoreboard
for (int i =0; i < 5; i++)
rolls.add(0); // intialize arraylist
score = 0;
}
public void setRoll(int idex, int val)
{
rolls.set(idex, val);
}
public void sortRoll()
{
Collections.sort(rolls);
}
public int getRoll(int idex)
{
return rolls.get(idex);
}
public int getScoreboard(int idex)
{
return scoreBoard[idex];
}
public void setScoreboard(int idex, int val)
{
if(scoreBoard[idex]==-1) // for yahtzee case where setscore is called more than once for the category
scoreBoard[idex]=0;
scoreBoard[idex]+=val;
}
public int getBoardSize()
{
return scoreBoard.length;
}
public ArrayList<Integer> getRollList()
{
return rolls;
}
public int getScore()
{
return score;
}
public void setScore()
{
int currentScore=0;
for(int i =0; i <13;i++)
{
if(getScoreboard(i)!=-1) // for yahtzee case where setscore is called more than once for the category
currentScore+=getScoreboard(i);
}
score=currentScore;
}
public void bonus()
{
score+=35;
}
public int getRollSize()
{
return rolls.size();
}
}