This project implements a minimal aircraft simulation program based on a given UML class diagram. It uses Object-Oriented principles and design patterns such as Observer, Singleton, and Factory to ensure extensibility and maintainability.
-
Simulates aircraft behavior in response to weather changes.
-
Logs detailed messages for aircraft actions, including registration, unregistration, and weather-induced behavior.
-
Validates input scenarios and handles errors gracefully using custom exceptions.
-
Java version: Latest LTS (e.g., OpenJDK 17+)
-
Build tools: None (no external libraries or tools are allowed).
.
├── avaj_Launcher.iml
├── LICENSE
├── README.md
├── ressources
│ ├── avaj_uml.png
│ ├── global.puml
│ └── scenario.txt
├── simulation.txt
├── sources.txt
└── yuboktae
├── factory
│ ├── AircraftFactory.class
│ └── AircraftFactory.java
├── InvalidInputException.class
├── models
│ ├── Aircraft.class
│ ├── Aircraft.java
│ ├── Baloon.class
│ ├── Baloon.java
│ ├── Coordinates.class
│ ├── Coordinates.java
│ ├── Helicopter.class
│ ├── Helicopter.java
│ ├── JetPlane.class
│ └── JetPlane.java
├── observer
│ ├── Flyable.class
│ ├── Flyable.java
│ ├── Tower.class
│ ├── Tower.java
│ ├── WeatherTower.class
│ └── WeatherTower.java
├── SimulationException.class
├── SimulationException.java
├── Simulator.class
├── Simulator.java
├── singleton
│ ├── WeatherProvider.class
│ └── WeatherProvider.java
├── Tracker.class
└── Tracker.java
6 directories, 35 files
In the root directory of your project, compile the program with:
find * -name "*.java" > sources.txt
javac @sources.txt
Run the program using the following command:
java yuboktae.Simulator ressources/scenario.txt
- The simulation generates a file simulation.txt describing the outcome.
The scenario.txt file should contain:
-
First line: A positive integer representing the number of weather changes.
-
Subsequent lines: Each line describes an aircraft in the format:
TYPE NAME LONGITUDE LATITUDE HEIGHT- TYPE: Aircraft type(
Baloon,Helicopter, orJetplane). - NAME: Aircraft name.
- LONGITUDE, LATITUDE, HEIGHT: Positive integers. Height must be in range 0-100.
- TYPE: Aircraft type(
5
Baloon B1 45 32 12
Helicopter H1 50 25 90
JetPlane J1 10 20 30
-
Coordinates are positive numbers.
-
Height is limited to the range 0-100.
-
Aircrafts receive unique IDs.
-
Aircraft lands and unregisters if height reaches or falls below 0.
-
Aircraft logs messages for weather changes and actions.
- Weather-triggered messages:
TYPE#NAME(UNIQUE_ID): SPECIFIC_MESSAGE - **Registration/Unregistration messages: Messages are logged when an aircraft registers or unregisters from WeatherTower.
Baloon#B1(1): It's raining. Let’s enjoy the ground!
Helicopter#H1(2): It's sunny. Perfect for a flight.
JetPlane#J1(3): It's foggy. Can't see a thing!
-
The program validates input data. If the input is invalid, the program stops execution and prints error messages to the standard output.
-
Custom exception, such as
SimulationExceptionis used to handle errors.
-
Custom Exceptions: The project includes
SimulationExceptionfor better error handling. -
Funny messages: Aircraft log funny messages for weather changes.
Refer to the UML diagram in ressources/avaj_uml.png for class structure and relationships.
This project is licensed under the MIT License.
Yulia Boktaeva