For this exercise you are given Java code that has been poorly engineered. Your task is to examine the code and refactor it to use a specific design pattern.
Once you have refactored the design to use the required design pattern, complete the GoF pattern card in the refactoring design document. Remember to use context specific names for your classes (i.e. avoid using names like "Context," "Client," "Subject," etc.). You should also write at least 2-3 sentences describing each class's role in the pattern within the context of this system; do not use generic descriptions of the class roles in the pattern (i.e. "This class is the observer," or "This class is the client.").
Create a UML diagram of your refactored subsystem. Your diagram should completely capture all of the relationships between classes in the subsystem using proper UML notation. Be sure to include the pattern stereotype for any class that is playing a role in the design pattern by including the name of the role in guillemets beneath the name of the class, e.g. <<Context>>
Finally, you should implement the refactoring on the provided source code and include your refactored code as a ZIP file along with your submission.
Your team is taking over development of a multi-player space combat simulator. In the game, all players are given a basic space ship when they create a new, level 1 player. When players reach the current maximum level of 10, they can choose from one of three upgrades:
In the current design, these ships are each implemented as a separate class. However, the game has been more successful than anticipated and players would like the maximum level increased. The previous development team started a design that would raise the maximum level that players can achieve to 30. Players would get the following perks:
The previous team's design was to continue creating subclasses for each possible combination of ship upgrades. The game publisher realized that this was a bad design and would quickly lead to combinatorial class explosion. This is why the previous team was fired and you were brought on. Show the publisher that you are worth your $300/hour consultation fee by refactoring the current design to support a path to the level 20 and 30 upgrades as well as the addition of future expansion content by leveraging the Decorator Design Pattern. See the code in the provided ZIP file for the current design of the implemented space ships.
You have been provided with a JUnit 4 unit test that tests the various methods on the different spacecraft and verifies the behavior of each. Feel free to examine this test class if you'd like, but don't worry if you don't understand what it does or how it does it. You will need to modify this test after you have refactored the design.
If you are using IntelliJ, support for JUnit 4 is integrated into the development environment. The JUnit test file will not compile by default in a new project. In IntelliJ, you will need to open the test file in the editor and click to place your cursor on one of the @Test attributes. Then use alt-enter to add JUnit 4 as a dependency to your project. If you are using an IDE other than IntelliJ, you are on your own to figure out how to get JUnit 4 to work with your IDE.
By the time specified in the course schedule, submit your refactored design document, and your refactored source code Observer Refactoring dropbox.