-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScore.java
38 lines (32 loc) · 847 Bytes
/
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
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Font;
public class Score{
private int s;
// sets score to zero initially
public Score(){
s = 0;
}
// increases score by one
public void incScore(){
s++;
}
// returns the score variable
public int getScore(){
return s;
}
// displays the score onto the window
public void scoreDisplay(Graphics window){
String score = "Score: " + getScore();
window.setFont(new Font("TAHOMA", Font.BOLD, 13));
window.setColor(Color.BLACK);
window.drawString(score, 200,300);
window.setColor(Color.WHITE);
}
// clears the score on the window and resets to zero
public void scoreClearNotOverlap(Graphics window){
String score = "Score: " + getScore();
window.setColor(Color.WHITE);
window.drawString(score, 200,300);
}
}