-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplays.java
More file actions
65 lines (58 loc) · 1.51 KB
/
Displays.java
File metadata and controls
65 lines (58 loc) · 1.51 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
/*
* File: Displays.java
* ------------------------
* The class Displays have different types of objects including
* images and labels. Each performs a different function in the game.
* The final adding of these objects to the screen is by calling
* the addDisplay method in the Background class.
*/
import acm.graphics.GImage;
import acm.graphics.GLabel;
public class Displays implements Constants {
// Two types of Displays for this program:
private GLabel lbl;
private GImage img;
// Constructor: takes a string (indicating what this object is)
// and an int which would be useful if the Displays objects is a label.
public Displays(String str, int pts) {
switch (str) {
case "Title":
img = new GImage(TITLEIMG_FILENAME);
break;
case "ClickToStart":
img = new GImage(CLICK_START_FILENAME);
break;
case "GameOver":
img = new GImage(GAMEOVER_FILENAME);
break;
case "Score":
img = new GImage(SCOREMSG_FILENAME);
break;
case "Points":
lbl = new GLabel(Integer.toString(pts));
lbl.setFont("Chalkboard-30");
case "PointsOnScreen":
lbl = new GLabel(Integer.toString(pts));
lbl.setFont("Chalkboard-24");
case "Instructions":
img = new GImage(INFO_FILENAME);
break;
case "InstructionLabel":
img = new GImage(INFOLABEL_FILENAME);
break;
case "ClickToQuit":
img = new GImage(CLICK_QUIT_FILENAME);
break;
default:
img = null;
}
}
// Label getter.
public GLabel getLbl() {
return lbl;
}
// Image getter.
public GImage getImg() {
return img;
}
}