-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.java
More file actions
54 lines (47 loc) · 1.35 KB
/
Timer.java
File metadata and controls
54 lines (47 loc) · 1.35 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
// Name: Dana Hum & Charlie To
// Date: January 18th, 2023
// Teacher: Ms. Basaraba
// Descritpion: 2 minute count down timer
import java.awt.*; // access to java files
import hsa.Console; // access to Console class
import java.lang.*; // to access Thread Class
public class Timer extends Thread
{
private Console c; // private console
public void timer () // timer method
{
int border = 5;
for (int x = 120 ; x >= 0 ; x--)
{
c.setFont (new Font ("SansSerif", Font.BOLD, 27));
c.setColor (Color.BLACK);
c.fillRoundRect (455-border, 25-border, 100 + border*2, 50+border*2, 10, 10);
c.setColor (new Color (250, 94, 82));
c.fillRoundRect (455, 25, 100, 50, 10, 10);
c.setColor (Color.BLACK);
c.drawString (x + "", 480, 60);
try
{
Thread.sleep (1000); // delay
}
catch (Exception e)
{
}
}
c.setColor (new Color (60, 158, 250)); // sets color to bg
c.fillRect (0, 0, 800, 500);
c.setColor (Color.BLACK);
c.setFont (new Font ("SansSerif", Font.BOLD, 60));
c.drawString ("TIMES UP", 100, 100);
c.setFont (new Font ("SansSerif", Font.PLAIN, 40));
c.drawString ("Press the space bar to end", 100, 200);
}
public Timer (Console con) // setting console to c
{
c = con;
}
public void run ()
{
timer ();
}
}