-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathViewController.java
75 lines (64 loc) · 2.33 KB
/
ViewController.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
import java.util.ArrayList;
import java.io.*;
public class ViewController{
private ArrayList<Integral> integrals;
private int activeIntegral;
private Integral defaultIntegral;
private boolean isDisplayingAnswer;
private final int TIME_LIMIT = 180;
private DisplayFrame displayFrame;
private ControllerFrame controllerFrame;
private String getFileName(int number){
String strNum = "" + number;
while(strNum.length() < 3){
strNum = "0" + strNum;
}
return Launcher.PDF_FILENAME + "-page-" + strNum + ".jpg";
}
public ViewController(String filename){
activeIntegral = -1;
defaultIntegral = new Integral("", 0, "white.jpg", "white.jpg");
integrals = new ArrayList<Integral>();
isDisplayingAnswer = false;
File infoFile = new File(filename);
int i=0;
try{
BufferedReader reader = new BufferedReader(new FileReader( infoFile ));
while( reader.ready() ){
integrals.add(new Integral(reader.readLine(),
Integer.parseInt(reader.readLine()), getFileName(i+1), getFileName(i+2)));
i += 2;
}
}
catch (IOException e){
System.out.println(e);
}
}
public Integral getActiveIntegral(){
return (activeIntegral == -1) ? defaultIntegral : integrals.get(activeIntegral);
}
public ArrayList<Integral> getAllIntegrals(){
return integrals;
}
public void setActiveIntegral(int val){
activeIntegral = val;
isDisplayingAnswer = false;
displayFrame.displayIntegral();
}
public void toggleAnswer(){
isDisplayingAnswer = !isDisplayingAnswer;
displayFrame.repaint();
}
public boolean getDisplayingAnswer(){
return isDisplayingAnswer;
}
public void updateScoreBoard(String player1, String score1, String player2, String score2, String player3, String score3, String player4, String score4){
displayFrame.updateScoreBoard(player1, score1, player2, score2, player3, score3, player4, score4);
}
public void setDisplayFrame(DisplayFrame frame){
displayFrame = frame;
}
public void setControllerFrame(ControllerFrame frame){
controllerFrame = frame;
}
}