{"id":17727649,"url":"https://github.com/tuanh00/aircraftmanagement_designpatterns","last_synced_at":"2026-05-01T14:33:54.369Z","repository":{"id":259368079,"uuid":"877433827","full_name":"tuanh00/AircraftManagement_DesignPatterns","owner":"tuanh00","description":"This repository contains a Java application that implements three design patterns: Builder, Abstract Factory, and State patterns. The project also includes comprehensive JUnit tests to verify functionality and ensure smooth operation.","archived":false,"fork":false,"pushed_at":"2024-10-24T04:57:03.000Z","size":381,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-24T22:12:39.476Z","etag":null,"topics":["abstract-factory-pattern","builder-design-pattern","console-application","drawio","intellij","java","junit5","state-pattern"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuanh00.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-23T16:34:57.000Z","updated_at":"2024-10-24T04:59:23.000Z","dependencies_parsed_at":"2024-10-24T22:24:28.152Z","dependency_job_id":"bc81035a-85e9-42a9-84d0-c66e91f317d7","html_url":"https://github.com/tuanh00/AircraftManagement_DesignPatterns","commit_stats":null,"previous_names":["tuanh00/aircraftmanagement_designpatterns"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanh00%2FAircraftManagement_DesignPatterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanh00%2FAircraftManagement_DesignPatterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanh00%2FAircraftManagement_DesignPatterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanh00%2FAircraftManagement_DesignPatterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuanh00","download_url":"https://codeload.github.com/tuanh00/AircraftManagement_DesignPatterns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246490948,"owners_count":20786086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstract-factory-pattern","builder-design-pattern","console-application","drawio","intellij","java","junit5","state-pattern"],"created_at":"2024-10-25T18:07:11.582Z","updated_at":"2026-05-01T14:33:54.302Z","avatar_url":"https://github.com/tuanh00.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aircraft Management _ Applied Design Patterns\n\nThis repository contains a Java application that implements three design patterns: `Builder`, `Abstract Factory`, and `State` patterns. The project also includes comprehensive **JUnit** tests to verify functionality and ensure smooth operation.\n\n## 📝 Description\n\nThe **Aircraft Management System** is a simulation that models the behavior of aircraft using various design patterns. The primary goal is to apply these design patterns to structure an application that can manage aircraft attributes, states, and operations effectively.\n\nThis project implements:\n\n- **Builder Pattern**: For constructing complex airplane and airship objects step by step.\n- **Abstract Factory Pattern**: To create families of related objects without specifying their concrete classes.\n- **State Pattern**: To manage different states of the aircraft such as engine state, landing state, and mode.\n\nA test suite using **JUnit** ensures all parts of the system function as intended, covering scenarios like altitude changes, aircraft crashes, and repair procedures.\n\n![UML Diagram](./airplaneSimulatorDiagram.drawio.png)  \n\nThe UML diagram above illustrates the relationships between the classes in this project.\n\n## 🚀 Deployment\n\nThis project is structured to be deployed and run locally using IntelliJ IDEA or any Java-compatible IDE. The following steps outline how to clone and run the project.\n\n### 💻 Installation\n\nTo get the project up and running locally:\n\n```bash\n# Clone the repository\ngit clone https://github.com/tuanh00/AircraftManagement_DesignPatterns.git\n\n# Navigate into the project directory\ncd AircraftManagement_DesignPatterns\n\n# Open the project in IntelliJ IDEA (or your preferred Java IDE)\n# Ensure JUnit is available for unit testing\n```\n## 📋 Requirements\n- Java version 20.0.2\n- JUnit for testing version 5.8.1\n## 🎨 Features\nDesign Patterns: Implements Builder, Abstract Factory, and State patterns for structured and scalable code.\nAircraft States: The aircraft can be in different states (e.g., Crashed, Good, On, Off, OnGround, InAir).\nTesting: A JUnit test helps to verify the correctness of aircraft operations.\nUML Diagram: A UML diagram illustrates the overall system design.\n## 📜 Unit Testing\nThe test suite checks the following scenarios:\n- Airplane Creation: Testing the creation of an airplane with default values.\n```bash\n  @Test\n    @DisplayName(\"Create an airplane with default values\")\n    void testCreateAirplaneWithDefaults() {\n        assertNotNull(airplane, \"Airplane should be created\");\n        assertEquals(1, airplane.getAirplaneId(), \"First airplane ID should be 1\");\n        assertEquals(Good.Instance(), airplane.getCurrentAircraftState(), \"Default aircraft state should be Good\");\n        assertEquals(OFF.Instance(), airplane.getCurrentEngineState(), \"Default engine state should be Off\");\n        assertEquals(No.Instance(), airplane.getCurrentLandingState(), \"Default landing state should be No\");\n        assertEquals(OnGround.Instance(), airplane.getCurrentModeState(), \"Default mode state should be OnGround\");\n        assertEquals(0, airplane.getAltitude(), \"Default altitude should be 0\");\n    }\n```\n- Altitude Changes: Ensuring the aircraft can increase and decrease altitude safely.\n```bash\n @Test\n    @DisplayName(\"Decrease altitude under safe conditions\")\n    void testDecreaseAltitudeAsDefault() {\n        airplane.increaseAltitude(-1);\n        airplane.triggerMode();\n        airplane.decreaseAltitude(1000);\n\n        ModeState currentModeState = airplane.getCurrentModeState();\n        LandingState currentLandingState = airplane.getCurrentLandingState();\n\n        assertEquals(OnGround.Instance(), currentModeState, \"Should be on ground\");\n        assertEquals(Yes.Instance(), currentLandingState, \"Should be in landing\");\n        assertEquals(0, airplane.getAltitude(),\n                \"Altitude should be decrease to 0\");\n    }\n```\n- Handling dangerous altitude warnings and airplane crashes.\n```bash\n    @Test\n    @DisplayName(\"Test for dangerous altitude warning\")\n    void testDangerousAltitudeWarning() {\n        airplane.increaseAltitude(10000);\n        AircraftState currentState = airplane.getCurrentAircraftState();\n        assertEquals(Good.Instance(), currentState, \"Should warn of dangerous altitude at 10000 feet\");\n    }\n```\n- Crash and Repair: Simulating an aircraft crash and testing the repair functionality.\n```bash\n @Test\n    @DisplayName(\"No actions allowed after crash except repair\")\n    void testNoActionsAfterCrash() {\n        airplane.increaseAltitude(12000); // This should crash the airplane\n\n        // Assert airplane is still crashed\n        assertEquals(Crashed.Instance(), airplane.getCurrentAircraftState(), \"Should explode at 12000 feet\");\n        // Then repair and check states\n        airplane.repair();\n        assertAll(\n                () -\u003e assertEquals(1, airplane.getAirplaneId(), \"First airplane ID should be 1\"),\n                () -\u003e assertTrue(airplane.getCurrentAircraftState() instanceof Good, \"Airplane should be in Good state after repair.\"),\n                () -\u003e assertTrue(airplane.getCurrentEngineState() instanceof OFF, \"Engine should be OFF after repair.\"),\n                () -\u003e assertTrue(airplane.getCurrentLandingState() instanceof No, \"Landing state should be NO after repair.\"),\n                () -\u003e assertEquals(0, airplane.getAltitude(), \"Altitude should be reset to 0 after repair.\")\n        );\n    }\n```\n## 👥 Contributing\nContributions are welcome! If you find a bug or have suggestions for new features or improvements, feel free to open an issue or submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuanh00%2Faircraftmanagement_designpatterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuanh00%2Faircraftmanagement_designpatterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuanh00%2Faircraftmanagement_designpatterns/lists"}