-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAircraftSpecsDatabase.java
29 lines (23 loc) · 1.03 KB
/
AircraftSpecsDatabase.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
import java.util.*;
public class AircraftSpecsDatabase {
private HashMap<Integer, AircraftSpecs> aircrafts;
// Create Singleton Instance of the AirportDatabase Class
private static final AircraftSpecsDatabase instance = new AircraftSpecsDatabase();
private AircraftSpecsDatabase() {
aircrafts = new HashMap<Integer, AircraftSpecs>();
this.add(new AircraftSpecs(CONSTANTS.SINGLE_ENGINE, "Single-Engine", 60, 110, 280, 8000, 700, 3));
this.add(new AircraftSpecs(CONSTANTS.TURBO, "Turbodrom", 100, 220, 4200, 16000, 1200, 9));
this.add(new AircraftSpecs(CONSTANTS.JET, "Jet", 140, 280, 16000, 28000, 2300, 15));
}
public static AircraftSpecsDatabase getInstance() {
return instance;
}
// Adds aircraft in database
public void add(AircraftSpecs aircraft) {
this.aircrafts.put(aircraft.getType(), aircraft);
}
// Returns the specs for specific type of aircraft
public AircraftSpecs getAircraftSpecsByType(int type) {
return aircrafts.get(type);
}
}