-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelevators3.java
More file actions
55 lines (49 loc) · 2.05 KB
/
elevators3.java
File metadata and controls
55 lines (49 loc) · 2.05 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
import java.io.*;
import java.util.Properties;
/***
* @author EvaDeThomas
*
* For information on implimentation and methods see detailed comments and README file.
* */
/*Elevators3 class (the main class) either takes in a given properties file or it uses the built-in one. */
public class elevators3 {
static String structures;
static int floorNumber;
static double passengers;
static int elevatorNumber;
static int elevatorCapacity;
static int duration;
public static void main(String[] args) throws Exception {
//Creating a properties instance
Properties prop = new Properties();
//if no arguments given, use inherent property file.
if (args.length < 1) {
FileReader propFile = new FileReader("properties.db");
prop.load(propFile);
} else {
/*If given an argument, read in the file and load properties from it. Try and catch catches any error
messages */
try {
FileReader propFile = new FileReader(args[0]);
prop.load(propFile);
} catch (Exception e) {
System.out.println("Error reading file");
System.exit(0);
}
}
/* Setting variables based on property files. */
structures = prop.getProperty("structures");
floorNumber = Integer.parseInt(prop.getProperty("floors"));
elevatorNumber = Integer.valueOf(prop.getProperty("elevators"));
passengers = Double.valueOf(prop.getProperty("passengers"));
elevatorCapacity = Integer.valueOf(prop.getProperty("elevatorCapacity"));
duration = Integer.valueOf(prop.getProperty("duration"));
/*
Commented out prints for testing:
System.out.println(structures+ " " + floorNumber+ " " + elevatorNumber+ " " + passengers+ " " + elevatorCapacity+ " " + duration);
*/
/*Creating an instance of the simulation to actually run it.*/
ElevatorSimulator simulation = new ElevatorSimulator();
simulation.runSimulation();
}
}