-
Notifications
You must be signed in to change notification settings - Fork 0
/
Score.java
52 lines (45 loc) · 1.04 KB
/
Score.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
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
public class Score extends ScreenObject
{
private int score;
/**
* Create the score at a particular location and size.
* The score starts at zero.
* @param location The starting location.
* @param size The size.
*/
public Score(Point location, Rectangle size)
{
super(location, size);
score = 0;
}
/**
* To draw the score, convert the integer to a string.
*/
@Override
public void draw(Graphics g)
{
//draw the score display
g.setColor(Color.white);
g.setFont(new Font("Times New Roman",Font.BOLD, 24));
g.drawString("SCORE:"+ score, location.x, location.y);
}
/**
* Retrieve the score.
* @return the score
*/
public int getScore() {
return score;
}
/**
* Change the score.
* @param score the score to set
*/
public void setScore(int score) {
this.score = score;
}
}