-
Notifications
You must be signed in to change notification settings - Fork 0
/
Methods.java
83 lines (61 loc) · 1.93 KB
/
Methods.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
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
import java.util.Random;
import java.awt.Color;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.io.PrintWriter;
public abstract class Methods {
static Color backgroundColor = new Color(43,43,43);
static Color foregroundColor = new Color(240,240,240);
static Color borderColor = new Color(189,81,81);
public static void ChangeColor(Color bC){
borderColor = bC;
}
static int [] c ;
static int index, i ,j ;
static boolean v ;
static Random rand = new Random();
static void QuestionsIndex(int []cp){
i = 0 ;
c = cp ;
while( i != c.length ){
v = true ;
index = rand.nextInt(c.length+1);
j = 0;
while(v == true && j != c.length ){
if(index == c[j])
v = false;
j++;
}
if(v == true){
c[i] = index;
i++;
}
}
}
static File bs = new File("best-score.txt");
static int readBestScorefromTheFile(){
try{
Scanner scn = new Scanner(bs);
String s = scn.nextLine();
scn.close();
return Integer.parseInt(s);
}
catch(FileNotFoundException fe){}
return 0 ;
}
static void writeBestScoreInTheFile(){
try{
int cBestScore = readBestScorefromTheFile();
PrintWriter ws = new PrintWriter(bs);
if(QuestionWindow.results() > cBestScore )
ws.print( QuestionWindow.results());
else if ( QuestionWindowE.results() > cBestScore )
ws.print( QuestionWindowE.results() );
else
ws.print( cBestScore );
ws.close();
}
catch(FileNotFoundException fe){}
}
}