-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrid.java
More file actions
102 lines (81 loc) · 1.76 KB
/
Grid.java
File metadata and controls
102 lines (81 loc) · 1.76 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
package MemoryGrid;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.*;
@SuppressWarnings("serial")
public class Grid extends JFrame
{
protected static int dimension=960;
protected static int mode=0;
protected static int cd=240;
protected int pairs;
protected List<Card> cards;
protected int display(List<BufferedImage> cardVals) throws FileNotFoundException
{
File file = new File(GameSystem.theme);
Scanner scan=new Scanner(file);
String path;
BufferedImage image = null;
int dummies=0;
if(Grid.cd==240)
{
this.pairs=8;
if (Grid.mode==1)
{
dummies=1;
}
}
else if (Grid.cd==160)
{
this.pairs=18;
if (Grid.mode==1)
{
dummies=2;
}
}
else
{
this.pairs=32;
if (Grid.mode==1)
{
dummies=4;
}
}
this.cards=new ArrayList<Card>();
int i=0;
int j=0;
while(scan.hasNext() && i<(this.pairs-dummies) )
{
path=scan.next();
try
{
image = ImageIO.read(new File(path));
cardVals.add(image);
if (j<dummies)
{
path=scan.next();
image = ImageIO.read(new File(path));
cardVals.add(image);
j+=1;
}
else
{
cardVals.add(image);
i+=1;
}
}
catch (Exception e)
{
System.out.println("Image cannot be loaded");
}
}
j=0;
scan.close();
return(this.pairs-dummies);
}
}