AvajLauncher is a simulation program that models the behavior of various aircraft in different weather conditions.
The program reads a scenario file, validates its content, and simulates the behavior of the aircraft based on the provided instructions.
This project is developed as part of the 42 school curriculum, aiming to teach students about object-oriented programming, design patterns, and exception handling.
- Clone the repository:
git clone https://github.com/Kiripiro/avaj-launcher.git
- Navigate to the project directory:
cd avaj-launcher
- Build and run the project:
- Using the provided
run.sh
script:sh run.sh
- Or using Make:
make [optional target]
- Using the provided
- all: Compile the project, copy resources, and run the program.
make all
- compile: Compile the Java source files.
make compile
- copy-resources: Copy the resources to the build directory.
make copy-resources
- run: Run the program.
make run
- clean: Clean the compiled files.
make clean
- fclean: Perform a full clean, including the build directory and sources.txt file.
make fclean
- re: Perform a full clean and then rebuild the project.
make re
Ensure you have the following installed:
- Java Development Kit (JDK) 8 or higher
- Make (optional, for using the Makefile)
Make sure the project has been properly built before running the simulation.
To run the simulation, use the following command:
java -classpath "build/classes:build/resources" com.atourret.avajLauncher.Main scenario.txt
Here is the output screenshot.
Here's an example of what a scenario file might look like:
25
Baloon B1 2 3 20
Baloon B2 1 8 66
JetPlane J1 23 44 32
Helicopter H1 654 33 20
Helicopter H2 22 33 44
Helicopter H3 98 68 99
Baloon B3 102 22 34
JetPlane J2 11 99 768
Helicopter H4 223 23 54
src/main/
├── java/com/atourret/avajLauncher/
│ ├── exceptions/
│ │ ├── InvalidScenarioException.java
│ │ └── ParsingErrorException.java
│ ├── interfaces/
│ │ └── Flyable.java
│ ├── models/
│ │ ├── Aircraft.java
│ │ ├── AircraftFactory.java
│ │ ├── Baloon.java
│ │ ├── Coordinates.java
│ │ ├── Helicopter.java
│ │ ├── JetPlane.java
│ │ ├── Tower.java
│ │ └── WeatherTower.java
│ ├── parser/
│ │ ├── Parser.java
│ │ └── Validator.java
│ ├── scenario/
│ │ └── Scenario.java
│ ├── services/
│ │ └── WeatherProvider.java
│ └── Main.java
└── resources/
└── scenario.txt
- exceptions/: Contains custom exception classes used for error handling.
- interfaces/: Defines interfaces that must be implemented by various models.
- models/: Contains the core classes representing different aircraft and their behaviors.
- parser/: Responsible for reading and validating the scenario file.
- scenario/: Manages the simulation logic.
- services/: Provides weather-related services.
- Main.java: Entry point of the application.
- resources/: Contains external files such as the scenario.txt file.
The entry point of the application.
It validates the command-line arguments, parses the scenario file, and starts the simulation.
Singleton class that manages the simulation.
It holds the list of aircraft and the number of simulations to run.
Responsible for reading and validating the scenario file.
It parses the file and initializes the Scenario instance with the appropriate data.
Interface that must be implemented by all aircraft.
It defines methods for updating conditions and registering with the WeatherTower.
- Aircraft.java: Base class for all aircraft types.
- Baloon.java, Helicopter.java, JetPlane.java: Specific implementations of different aircraft.
Thrown when there is an error in parsing the scenario file.
Thrown when the scenario file contains invalid data.
Here is the UML diagram we had to implement.
The detailed project description can be found in the assets/en.subject.pdf file.