-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoodbye.java
More file actions
78 lines (63 loc) 路 3.51 KB
/
Copy pathGoodbye.java
File metadata and controls
78 lines (63 loc) 路 3.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
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Name: Chelsea Wong & Annie Wong
Teacher: Ms. Basaraba
Date: January 18th, 2022
Description: This program draws the Goodbye screen for the Crossword game.
This screen is the screen right before the user presses a key
to close the game/window.
ISP: Crossword
*/
import java.awt.*; //gives access to java command library
import hsa.Console; //gives access to the Console class from the hsa library
import java.io.*; //gives access to the input output commands
public class Goodbye{ //the Goodbye class, draws the screen right before the user presses a key to close the game/window
Console c; //declaration of instance variable of the Console class; the output console
// imports the font files
public void loadFonts() throws java.awt.FontFormatException, java.io.IOException {
Font.createFont(Font.TRUETYPE_FONT, (InputStream) new FileInputStream("Fonts\\Montserrat-Regular.ttf"));
Font.createFont(Font.TRUETYPE_FONT, (InputStream) new FileInputStream("Fonts\\Montserrat-Bold.ttf"));
Font.createFont(Font.TRUETYPE_FONT, (InputStream) new FileInputStream("Fonts\\Montserrat-Italic.ttf"));
Font.createFont(Font.TRUETYPE_FONT, (InputStream) new FileInputStream("Fonts\\Montserrat-BoldItalic.ttf"));
}
// declaration of font constants [variables are in full uppercase since they are constants are do not change throughout the program]
final Font TITLE = new Font ("Montserrat Bold", Font.PLAIN, 42); // font for title text for this screen
final Font BODY = new Font ("Montserrat Regular", Font.PLAIN, 20); // font for body text for this screen
final Font SMALL = new Font ("Montserrat Regular", Font.PLAIN, 12); // font for small text for this screen
// declaration of color constants [variables are in full uppercase since they are constants are do not change throughout the program]
final Color LPURPLE = new Color(232,231,252);
final Color MPURPLE = new Color(138, 138, 223);
final Color DPURPLE = new Color(87,88,208);
final Color WHITE = new Color(255,255,255);
final Color PWHITE = new Color(246, 245, 254);
public Goodbye (Console con) throws java.awt.FontFormatException, java.io.IOException{ //constructor for the class Goodbye
c = con; //to use the Console object passed as a parameter when creating an instance of this class
loadFonts();
}
public void goodbye(){
c.clear(); //clear the screen
//drawing the background [used across all screens]
c.setColor(DPURPLE);
c.fillRoundRect(50,50,632,572,20,20);
c.setColor(LPURPLE);
c.fillRoundRect(54,54,624,564,16,16);
//the title
c.setColor(PWHITE);
c.fillRoundRect(114,312,505,27,2,2); //the highlight/underline for the title
c.setColor(DPURPLE);
c.setFont(TITLE);
c.drawString("thank you for playing!",124,324);
//main text
c.setFont(BODY);
c.drawString("Word Cross programmed by:",223,372);
c.drawString("Annie Wong & Chelsea Wong", 220,396);
//instructions on keys
c.setFont(SMALL);
c.drawString("press any key to close the game",464,597); //instructions on bottom right
c.getChar(); //waits for key press to know when to close the window
try{
Thread.sleep(1000); // 1 second delay before closing the window
}
catch(Exception e){}
c.close(); //close the window
}
} // Goodbye class