Thursday, 17 January 2013



CSIT2 

Space Wars and Tactics (SWAT) 

Computer-based game 

PPD(1)  

a.      A project containing the Java source code for an interface called SWAT (as specified above). The project should be called cwk3-SWAT followed by your surname and initial. For example: cwk3-SWAT-ObamaO

b.      A document with a list of classes (as specified above). You may include a class diagram showing relationships between the classes.






A)

/**
 * @ Alex Frazer 12015549
 *
 * @ V1.0 08/02/2013
 */
public interface SWAT
{   
    /**Sets the admiral's name.
     * @param name the name you have chosen for the admiral.
     */
    public void admiralName(String name);
   
    /**Returns the state of specified force
     * @param frc the specified force
     * @return a String representation of the force's state
     */
    public String getState(Force frc);
   
    /**Returns the value of resources
     * @return a String representation of the resources
     */
    public String getResources();
  
    /**Returns the result of a force wanting to be activated.
     * activation will be successful if:
     * the force's state is docked
     * the admiral's talents are high enough
     * If the force is activated then it is removed from the
     * docked list, added to the fleet and a suitable
     * message returned. If the force is already activated, the
     * state of the force remains unchanged and a suitable message
     * is returned. If the admiral's talents are too low, the
     * state of the force remains unchanged and a suitable message
     * is returned.
     * @param frc the specified force
     * @return a String which includes force reference, force name
     * and giving the result of the request
     **/
    public String activateForce(Force frc);
   
    /**Returns the result of a fight with an enemy.
     * Force can only attack the enemy if:
     * the force's state is active
     * If the force is activated then the fight will take place,
     * with the result and a suitable message returned. If the
     * force is not active no fight takes place and a suitable
     * message returned.
     * @param ftNo the specified fight number
     * @return a String which includes force reference, force name
     * and giving the result of the request
     **/
    public String engage(int ftNO);
   
    /**Returns the result of a force wanting to be recalled.
     * recalling will be successful if: 
     * the force's state is either active or resting
     * If the force is recalled then it is removed from either the
     * active or resting list, added to the dock and a suitable
     * message returned. If the force is already docked, the
     * state of the force remains unchanged and a suitable message
     * is returned. If the force is decommissioned the state of the
     * force remains unchanged and a suitable message.
     * @param frc the specified force
     * @return a String which includes force reference, force name
     * and giving the result of the request
     */
    public String recallForce(Force frc);
   
    /**Returns a list of all forces in the fleet and their states
     * @return a String representation of all forces and their states of the fleet
     */
    public String getFleet();
   
    /**Returns a list of all docked forces
     * @return a String representation of all docked forces
     */
    public String getDock();
   
    /**Returns a list of all fights
     * @returns a String representation of all fights
     */
    public String getFights();
   
    /**Restores a force's state from resting to active
     * @param frc the force to be restored
     */
    public void restoreForce(Force frc);
   
    /**Returns a list of all games saved to load from
     * @return a String representation of all games saved
     */
    public String loadGame();
   
    /**Saves the game that is being played currently
     * @param name the name the game should be saved under
     */
    public void saveGame(String name);
}




B)


Classes
Wings  -           strikers
StarShip -        laser cannons, photon torpedos

WarBird -        cloaking
<<abstract>> Forces - reference, name, strength, activation cost, state
Fights -            fight no, type, name, strength, losses, gains
Admiral -         name, talents, all forces, all fights
SWAT -            no fields
IO –                 Admiral, Scanner


No comments:

Post a Comment