This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuit.java
92 lines (81 loc) · 1.68 KB
/
Quit.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
84
85
86
87
88
89
90
91
92
/**
* The instructions screen
*
* Last edit: 6/18/2020
* @author Celeste
* @version 1.0
* @since 1.0
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Quit extends Menu {
/**
* Contains the wuit screen graphics / GUI
*/
private MenuDrawing drawing;
/**
* Initializes and displays the drawing to the frame
*/
public Quit() {
loadButtons(new String[]{"yes", "no"});
drawing = new QuitDrawing();
Utility.changeDrawing(drawing);
bgm = new BGM("menus");
bgm.play();
}
/**
* Removes the drawing
*/
public void halt() {
CovidCashier.frame.remove(drawing);
for (Button btn : buttons) btn.deactivate();
timer.stop();
}
/**
* GUI for the quit screen
*/
public class QuitDrawing extends MenuDrawing {
/**
* Object constructor. Uses the superclass's constructor
*/
public QuitDrawing() {
super();
for (Button btn : buttons) btn.activate();
}
/**
* GUI display of the quit screen
* @param g the Graphics object to draw on
*/
@Override
public void display(Graphics g) {
g.setColor(Color.black);
g.setFont(Utility.TITLE_FONT_SMALL);
g.drawString("Are you sure",leftAlign,titleY);
for (Button btn : buttons) {
btn.draw(g);
if (btn.isClicked()) {
bgm.stop();
if (btn.getName().equals("no")) {
halt();
new MainMenu();
return;
} else {
CovidCashier.frame.dispose();
System.exit(0);
}
}
}
drawReceipt(g);
refreshScreen();
}
/**
* Returns the y-coordinate of the title
* @return the MainMenuDrawing object's titleY attribute
*/
@Override
public int getTitleY() {
return titleY;
}
}
}