-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
136 lines (104 loc) · 2.87 KB
/
Copy pathtest.java
File metadata and controls
136 lines (104 loc) · 2.87 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.imageio.ImageIO;
public class test extends Applet {
static Image image;
static String s;
static ArrayList<Image> arr = new ArrayList<Image>();
static ArrayList<Image> imageArr = new ArrayList<Image>();
static ArrayList<String> holding = new ArrayList<String>();
static ArrayList<String> RandomString = new ArrayList<String>();
static Map<String, Integer> map = new LinkedHashMap<String, Integer>();
static Map<Image, String> imap = new LinkedHashMap<Image, String>();
static Image[][] ImageMatrix = new Image[4][13];
public void init(){
}
public void paint(Graphics g) {
RandomLoop(g);
}
public static void Image(int num, String m ) {
try {
image = ImageIO.read(new File(num+m));
}catch(IOException e) {}
s = num + m;
}
public void OrderedLoop(Graphics g) {
int z = 1050;
for(int x = 15; x>=2; x--) {
z-=75;
Image(x, "c.gif");
g.drawImage(image, z, 0, this);
Image(x,"d.gif");
g.drawImage(image, z, 100, this);
Image(x, "h.gif");
g.drawImage(image, z, 200, this);
Image(x, "s.gif");
g.drawImage(image, z, 300, this);
}
repaint();
}
public static void Randomize() {
for(int x = 15; x>=2 ; x--) {
if(x==14)
continue;
Image(x, "c.gif");
arr.add(image);
holding.add(s);
Image(x, "d.gif");
arr.add(image);
holding.add(s);
Image(x, "h.gif");
arr.add(image);
holding.add(s);
Image(x, "s.gif");
arr.add(image);
holding.add(s);
}
imageArr.addAll(arr);
Collections.shuffle(arr);
}
public void Aces(Graphics g) {
Image(14, "c.gif");
g.drawImage(image, 1075, 100, this);
Image(14, "d.gif");
g.drawImage(image, 1075, 200, this);
Image(14, "h.gif");
g.drawImage(image, 1075, 300, this);
Image(14, "s.gif");
g.drawImage(image, 1075, 400, this);
}
public void makeMatrix() {
int index = 0;
for(int r = 0; r<ImageMatrix.length; r++)
for(int c = 0; c<ImageMatrix[r].length; c++)
ImageMatrix[r][c] = arr.get(index++);
}
public void RandomLoop(Graphics g) {
Randomize();
Aces(g);
makeMatrix();
int xdim = 75;
int ydim = 100;
for (int y = 100; y <= 100+ydim*3; y+=ydim) {
int c = 0;
for (int x = 100; x < 100+13*xdim; x+=xdim) {
g.drawImage(ImageMatrix[(y/100)-1][c++],x,y,this);
}
}
arr.removeAll(arr);
holding.removeAll(holding);
}
public void swap() {
Image temp = ImageMatrix[1][1];
ImageMatrix[1][1] = ImageMatrix[2][2];
ImageMatrix[2][2] = temp;
}
}