-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiceGame.java
More file actions
40 lines (39 loc) · 998 Bytes
/
DiceGame.java
File metadata and controls
40 lines (39 loc) · 998 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
package Practice.Game;
public class DiceGame {
private static String name;
private static int age;
private static double balance;
public static void setName(String name) {DiceGame.name = name;
}
public static String getName() {
return name;
}
public static void setAge(int age) {
if(age >= 18) {
DiceGame.age = age;
}
else {
System.out.print(" You are below 18");
System.exit(0);
}
}
public static int getAge() {
return age;
}
public static void deposit(double amount) {
if (amount >= 200) {
balance += amount;
}
}
public static double getBalance() {
return balance;
}
public static void withdraw(double amount) {
if (balance >= 1000 && amount <= (balance - 200)) {
balance -= amount;
}
else {
System.out.print("Error!.");
}
}
}