-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
43 lines (32 loc) · 1.14 KB
/
Main.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
import output.OutputData;
import payment.Payment;
import com.fasterxml.jackson.databind.ObjectMapper;
import fileio.InputData;
import java.io.File;
import java.io.FileWriter;
/**
* Entry point to the simulation
*/
public final class Main {
private Main() { }
/**
* Main function which reads the input file and starts simulation
*
* @param args input and output files
* @throws Exception might error when reading/writing/opening files, parsing JSON
*/
public static void main(final String[] args) throws Exception {
File file = new File(args[0]);
ObjectMapper objectMapper = new ObjectMapper();
InputData inputData = objectMapper.treeToValue(
objectMapper.readTree(file), InputData.class);
Payment payment = new Payment(inputData);
payment.basicRound();
OutputData outputData = new OutputData(inputData);
final String tobeWritten = new ObjectMapper().writeValueAsString(outputData);
File outFile = new File(args[1]);
FileWriter writer = new FileWriter(outFile);
writer.write(tobeWritten);
writer.close();
}
}