-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathValues.java
More file actions
161 lines (114 loc) · 3.26 KB
/
Values.java
File metadata and controls
161 lines (114 loc) · 3.26 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
public class Values {
//Inst Vars
private int lastPos;
private int[] lineVal;
public static int[][] gridVal;
public static int[][] pointsVal;
public static int[][] tophersVal;
public static String allNotes;
public static int product;
//default contructor
public Values(){
int lastPos = 0;
lineVal = new int[25]; //to be transcribed into gridVal
gridVal = new int[5][5];
pointsVal = new int[2][5]; //the first row will be the COLUMN
tophersVal = new int[2][5];//the second row will be the ROW
allNotes = "===================\nYour Notes: ";
product = 1;
}
public static void calcProduct(int level){
product = (int)(Math.pow(2, level +2)) * (int)(Math.pow(3, level +1)) ;
}
//populates lineVal with 0 1 2 and 3
public void popLineVal (int level){
for (int i = 0; i < 25; i ++){
if (i < 6){
lineVal[i] = 0;
}
else if (i < 8 + level){
lineVal[i] = 2;
}
else if (i < 10 + level){
lineVal[i] = 3;
}
else{
lineVal[i] = 1;
}
}
for (int i = 0; i < 25; i ++){
int ran = (int)(Math.random()*25);
int temp = lineVal[i];
lineVal[i] = lineVal[ran];
lineVal[ran] = temp;
}
calcProduct(level);
}
//transcribes the scrambled values in lineVal into grid format
public void popGridVal(){
for (int i = 0; i < 5; i ++){
for (int c = 0; c < 5; c ++){
gridVal[i][c] = lineVal[i*5 + c];
}
}
}
//==============================THE ABOVE FOCUSES ON THE GRID VALUES=====
//==============================THE BELOW FOCUSES ON COUNTING POINTS=====
//calculates the total number of points in a column
public int arrayColumnSum(int y){
int sum = 0;
for(int[] i: gridVal){
sum += i[y];
}
return sum;
}
//calculates the total number of points in a row
public int arrayRowSum(int x){
int sum = 0;
for(int i : gridVal[x] ){
sum += i;
}
return sum;
}
//populates pointsVal with the values from the array----Sum methods for display to call
public void popPoints(){
for(int i = 0; i < 5; i ++){
pointsVal[0][i] = arrayRowSum(i);
}
for(int i = 0; i < 5; i ++){
pointsVal[1][i] = arrayColumnSum(i);
}
}
//=====================THE ABOVE FOCUSES ON COUNTING POINTS======
//=====================THE BELOW FOCUSES ON COUNTING TOPHERS=====
//counts number of tophers in a column
public int arrayColumnTophers(int y){
int topherCtr = 0;
for(int[] i: gridVal){
if (i[y] == 0){
topherCtr++;
}
}
return topherCtr;
}
//counts number of tophers in a row
public int arrayRowTophers(int x){
int topherCtr = 0;
for(int i : gridVal[x] ){
if (i == 0)
{
topherCtr++;
}
}
return topherCtr;
}
//populates tophersVAL with values from the array---tophers methods for display to call
public void popTophers(){
for(int i = 0; i < 5; i ++){
tophersVal[0][i] = arrayRowTophers(i);
}
for(int i = 0; i < 5; i ++){
tophersVal[1][i] = arrayColumnTophers(i);
}
}
}