This project is a simple defense system simulator created to practice and demonstrate object-oriented programming (OOP) concepts in Java.
The system features a main controller that manages various defense units, including a Helicopter, a Tank, and a Submarine.
- Multiple defense units: Supports three types of defense units — Helicopter, Tank, and Submarine.
- Centralized control: A
MainControllerallows the user to manage and interact with all defense units from a single interface. - Real-time communication: Defense units can send and receive messages from the main controller in real time.
- Observer pattern: The system uses the observer pattern to notify all defense units of any changes in the environment (e.g.,
"Area Clear").
This project demonstrates the following key OOP concepts:
-
Inheritance:
TheHelicopter,Tank, andSubmarineclasses all implement theSuperDefenceinterface, inheriting its methods and providing their own specific implementations. -
Polymorphism:
TheMainControllercan interact with all defense units through theSuperDefenceinterface, regardless of their specific type, allowing greater flexibility and extensibility. -
Encapsulation:
Each defense unit encapsulates its own data (e.g., ammo count, fuel level) and methods, hiding the internal implementation details from other objects. -
Observer Pattern:
TheMainControllerObservableclass acts as an observer, notifying all registered defense units of any changes in the environment, promoting loose coupling between the main controller and the defense units.
To run the project, you'll need:
- Java installed on your system
- NetBeans IDE for running the application
- Clone the repository to your local machine.
- Open the project in NetBeans.
- Run the
Starter.javafile to start the application.
- The main controller window will appear, along with the windows for each defense unit.
- Use the main controller to send messages to the defense units — either individually or as a broadcast.
- Mark the area as "clear" to enable the defense units' weapons.
- Each defense unit has its own controls, including:
- Sliders for fuel and ammo
- Buttons for firing weapons
Built with Java and NetBeans to demonstrate core OOP principles in a fun and interactive way.