-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLock.java
More file actions
40 lines (39 loc) · 995 Bytes
/
Copy pathLock.java
File metadata and controls
40 lines (39 loc) · 995 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
31
32
33
34
35
36
37
38
39
40
import java.awt.Font;
import java.awt.Graphics;
/*Lock.java
* @version 1.0
* @author Trotyl
* @since 2019.Dec.16
* A class that simulates a lock*/
public class Lock {
Font f = new Font("Couier", Font.PLAIN,100);
int num[]=new int[4];
Lock(){
for(int i=0;i<4;i++) {
}
}
public void up(int n) {//when the player clicks on the upper arrow
if(num[n-1]==9) {
num[n-1]=0;
}else {
num[n-1]++;
}
}
public void down(int n) {//when the player clicks on the down arrow
if(num[n-1]==0) {
num[n-1]=9;
}else {
num[n-1]--;
}
}
public String get() {
return num[0]+""+num[1]+""+num[2]+""+num[3];//returns the code of the lock
}
public void draw(Graphics g) {//draw the number on the lock
g.setFont(f);
g.drawString(num[0]+"", 300,300);
g.drawString(num[1]+"", 475,300);
g.drawString(num[2]+"", 650,300);
g.drawString(num[3]+"", 810,300);
}
}