-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
88 lines (55 loc) · 2.47 KB
/
Main.java
File metadata and controls
88 lines (55 loc) · 2.47 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import java.util.*;
public class Main {
static String command = "";
static int amount;
public static void main(String[] args) {
Simulation randumbFitnessStore = new Simulation(1000000, 1, 0.25);
Simulation you = new Simulation(100, 0);
Timer timer = new Timer();
TimerTask task1 = new TimerTask() {
@Override
public void run() {
you.userBalance += you.userStockAmount * randumbFitnessStore.singleStockDividendo ;
}
};timer.scheduleAtFixedRate(task1, 0, 2000);
Random random = new Random();
Timer changes = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
double randomNumber = 0.1 + (100.0 - 0.1) * random.nextDouble();
randumbFitnessStore.companySingleStockValue = randomNumber;
}
};changes.scheduleAtFixedRate(task, 0, 10000);
System.out.println("Read Tutorial on \"Tutorial File\"\n\n");
Scanner in = new Scanner(System.in);
while (command != "."){
command = in.nextLine();
if (Objects.equals(command, ".wallet")){
you.wallet();
} else if (Objects.equals(command, ".buy")) {
System.out.print("Amount: ");
amount = in.nextInt();
if (you.userBalance >= randumbFitnessStore.companySingleStockValue * amount){
you.userStockAmount += amount;
you.userBalance -= randumbFitnessStore.companySingleStockValue * amount;
randumbFitnessStore.companyAmountOfStocks -= amount;
}else{
System.out.println("Thou appearest to be of modest means.");
}
} else if (Objects.equals(command, ".sell")) {
System.out.print("Owned: " + you.userStockAmount + "\nAmount:");
amount = in.nextInt();
if (amount >= 1){
you.userBalance += amount * (randumbFitnessStore.companySingleStockValue * randumbFitnessStore.singleStockDividendo);
randumbFitnessStore.companyAmountOfStocks += amount;
you.userStockAmount -= amount;
}else{
System.out.println("Thou hast insufficient stocks.");
}
} else {
randumbFitnessStore.companyStatus();
}
}
}
}