-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIBinaryTextBoxResult.java
71 lines (60 loc) · 1.86 KB
/
IBinaryTextBoxResult.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import greenfoot.*;
public class IBinaryTextBoxResult extends Actor {
private GreenfootImage image;
private String eingabe;
private int vaules;
private int row;
private int col;
private int gameMode;
private int decimal;
private World world;
FGameModManger gameManager = FGameModManger.getInstance();
public IBinaryTextBoxResult(int row, int col, int gm) {
this.gameMode = gm;
this.col = col;
this.row = row;
image = new GreenfootImage("BinaryTextBoxResult.jpg");
switch (gameMode) {
case 1:
updateText("Deine Eingabe");
break;
case 2:
updateText(String.valueOf(decimal));
break;
default:
break;
}
}
public void act() {
switch (gameMode) {
case 1:
if (Greenfoot.mouseClicked(this)) {
eingabe = Greenfoot.ask("Bitte gebe die Dezimalzahl ein: ");
if (!eingabe.isEmpty()) {
this.vaules = Integer.parseInt(eingabe);
gameManager.checkInputGameModeOne(vaules, row, col);
updateText(eingabe);
}
}
break;
case 2:
updateText(String.valueOf(decimal));
break;
default:
break;
}
}
public void setDecimal(int decimals) {
this.decimal = decimals;
}
public void updateText(String newText) {
// Lösche den alten Text
image.clear();
image.drawString("", 45, 45);
image.clear();
image.setColor(Color.BLUE);
image.setFont(new Font("Arial", 20));
image.drawString(newText, 45, 45);
setImage(image);
}
}