-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLives.java
More file actions
30 lines (24 loc) · 785 Bytes
/
Lives.java
File metadata and controls
30 lines (24 loc) · 785 Bytes
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
import java.awt.*;
import javax.swing.*;
// Class that updates and displays amount of lives left
public class Lives {
int livesLeft = 3;
// Method to set lives and returns JLabel
public JLabel setLives(){
JLabel labelLives = new JLabel();
labelLives.setText("Lives: " + this.livesLeft);
labelLives.setForeground(Color.black);
labelLives.setFont(new Font("Serif", Font.BOLD, 24));
labelLives.setBounds(200, 75, 100, 100);
return labelLives;
}
//Method to update lives left and returns JLabel
public JLabel updateLives(){
this.livesLeft--;
return setLives();
}
// Method to get lives left and returns an int
public int getLives(){
return this.livesLeft;
}
}