Assignment 3 Janhavi-Pranav 1

DESIGN PATTERNS PROJECT 3

Team Members : Janhavi Virkar.
Pranav Shah.

Description:
In this third version of the breakout game we have implemented two design patterns namely Composite Design Pattern and Strategy Pattern. The Strategy Pattern is applied to the layout Manager framework whereas the entire game architecture has composite design pattern. The basic two functionalities required in the assignment were saving of session functionality and changing the layout from between flowlayout and borderlayout. These are implemented as follows:

LayoutManager:
There is a basic interface called LayoutManager which has one method layout() that takes a JComponent as an argument. JComponent is the component that has to be laid out either in a flow layout fashion or border layout. There are two classes BorderlayoutManager and FlowLayoutManager which implement the LayoutManager interface and override the layout() method. The layout manager (Flow or Border) that is to be called is decided at run time. We have written two customized layout functions for borderlayout and flowlayout and have not used the in build methods. We are changing the layout from flow to border in the Button Panel. The Strategy design pattern is followed here and flow of the program is:
1.ChangeLayout.java(Outer Panel to the Button Panel and contains ChangeLayout Button) contains the action performed for the changelayout button which is called when the button is clicked.
2.ChangeLayoutManager.java class is called from action performed which passes flow further to either FlowLayoutManager.java or BorderLayoutManager.java.

Saving of Session:
There are two classes which help to store session i.e. SaveSession.java and one which helps to restore the session i.e. RestoreSession.java. When user clicks on Save button, all the commands that have been executed so far gets stored in the xml format i.e. session.xml. Now, once the game starts it checks whether the session.xml contains any commands or not. If it does not contain any command it starts from the start position whereas if session.xml contains any commands then it loads all the commands to respective Command Object i.e. BallCommand / PaddleCommand through CommandBean. If session was stored it asks user whether to continue from the previously saved game or whether to start a new game. If user wants to continue with the game then the game objects take the position from the previously saved session else the game is restarted.

Junit and Log4j:
We had added log4j to log all the exceptions that can be encountered and have written Junit (for 4 classes) to test individual functionalities.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.