-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnonclient class 4
44 lines (41 loc) · 1.03 KB
/
nonclient class 4
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
/******************************************************************************
Eric Zhang
Comp Sci 3
May 13, 2021
Card games Program
*******************************************************************************/
public class BlackjackHand extends Hand
{
public BlackjackHand ()
{
super ();
}
//Get the value of the Hand
public int getValue ()
{
Card current;
int cardVal = 0;
int handVal = 0;
boolean ace = false;
for (int i = 0; i < super.getSize(); i++)
{
current = super.getCard(i);
cardVal = current.getValue();
//check if 1 or 11 for Aces
if (cardVal > 10)
{
cardVal = 10;
}
else if (cardVal ==1)
{
ace = true;
}
handVal += cardVal;
}
if ((ace == true) && ((handVal + 10) <= 21))
{
handVal += 10;
}
return handVal;
}
}