forked from The-Pheonix21/Blackjack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblackJackApplet.java
55 lines (52 loc) · 1.28 KB
/
blackJackApplet.java
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
import java.awt.*;
import java.applet.*;
public class blackJackApplet extends Applet {
private cardImage [] picturesAreHard;
private cardImage [] picturesAreHard1;
private Deck deck;
private int width = 80;
private int height = 100;
public void init() {
this.picturesAreHard = new cardImage[2];
this.picturesAreHard1 = new cardImage[2];
Card temp;
deck = new Deck();
deck.shuffle();
for (int i = 0;i < 2; i++) {
temp = deck.dealCard();
picturesAreHard[i] = new cardImage(temp.getCardImage());
}
deck.shuffle();
for (int j = 0;j < 2; j++) {
temp = deck.dealCard();
picturesAreHard1[j] = new cardImage(temp.getCardImage());
}
}
public void paint(Graphics g) {
int countrow=0;
int x=100;
int y=100;
for (int i = 0;i < 2;i++) {
if ((i+1)%13==0) {
x=75+(width*(i%13)+(25*(i%13)));
}else {
x=75+(width*((i)%13))+(25*((i)%13));
}
y=50+(countrow*height);
picturesAreHard[i].draw(g,new Rectangle(x,y,width,height));
}
countrow=countrow+2;
for (int i = 0;i < 2;i++) {
if ((i+1)%13==0) {
x=75+(width*(i%13)+(25*(i%13)));
}else {
x=75+(width*((i)%13))+(25*((i)%13));
}
if ((i%13==0) && (i>9)) {
countrow++;
}
y=50+(countrow*height);
picturesAreHard1[i].draw(g,new Rectangle(x,y,width,height));
}
}
}