-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (35 loc) · 1.28 KB
/
Main.java
File metadata and controls
39 lines (35 loc) · 1.28 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
package org.example;
import org.example.Calculate.Calculate;
import org.example.Calculate.PreProcess;
import org.example.Input.Input;
import org.example.Output.Show;
import org.example.Repository.Repository;
import java.util.List;
import java.util.Stack;
public class Main {
private static int choice;
public static void main(String[] args) {
CalConfig calConfig = new CalConfig();
Calculate calculator = calConfig.calculate();
Repository repository = calConfig.repository();
Input input = calConfig.input();
Show show = calConfig.show();
PreProcess preProcess = calConfig.preProcess();
while (true) {
show.showMenu();
choice = input.inputChoice();
System.out.println();
if (choice == 1) {
List<String> records = repository.getRecords();
show.showRecords(records);
} else {
String expression = input.inputExpression();
Stack<String> expressionStack = preProcess.expressionToStack(expression);
int result = calculator.calculate(expressionStack);
repository.save(expression,result);
show.showResult(result);
}
System.out.println();
}
}
}