Software Engineering Group Project Group 2 Design ...Version 1.4 (Release) Aberystwyth University /...
Transcript of Software Engineering Group Project Group 2 Design ...Version 1.4 (Release) Aberystwyth University /...
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 1 of 21
Software Engineering Group Project – Group 2 Design Specification
Author: Amy Richards, Izabela Slawek, Jamie Hall Config Ref: DesignSpecGroup2
Date: 2017-04-05 Version: 1.4 Status: Release
Department of Computer Science,
Aberystwyth University,
Aberystwyth,
Ceredigion, SY23 3DB,
U.K.
©Aberystwyth University 2017
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 2 of 21
CONTENTS
CONTENTS…………...……………………………………………………….2
1. INTRODUCTION…..……………..…………………………………….....3
1.1. Purpose of This Document………….………………………….3
1.2. Scope…………………..…………….………..………………….3
1.3. Objectives……………………………..………………………….3
2. DECOMPOSITION DESCRIPTION..……………………………………4
2.1. Programs in System…………………………………………….4
2.2. Significant Classes in Each Program...……………………….4
2.3. Modules Shared Between Programs………………………….4
2.4. Mapping From Requirements to Classes……………………..6
3. DEPENDENCY DESCRIPTION………………………………………….6
3.1. Component Diagram…………………………………………….6
4. INTERFACE DESCRIPTION……………………………………………..7
4.1. Application Interface Specification…………………………….7
4.2. GameBoard Interface Specification……………………………7
4.3. ChanceCard Interface Specification…………………………..8
4.4. CrewCard Interface Specification……………………………...8
4.5. Treasure Interface Specification……………………………….9
4.6. Player Interface Specification…………………………………..9
4.7. Position Interface Specification…………………………….…12
4.8. GUI Interface Specification……………………………………13
4.9. PirateShip Interface Specification……………………………13
4.10. FlatIsland Interface Specification…………………………….14
4.11. PirateIsland Interface Specification…………………………..15
4.12. TreasureIsland Interface Specification………………………16
4.13. Place Interface Specification………………………………….16
4.14. Port Interface Specification……………………………………17
4.15. sortQueue Interface Specification…………………………....18
4.16. UniqueLocations Interface Specification…………………….18
5. DETAILED DESIGN…………………………………………………...…18
5.1. Sequence Diagrams…………………………………………...18
5.2. Significant Algorithms………………………………………….18
5.3. Significant Data Structures……………………………………20
REFERENCES……………………………………………………………21 DOCUMENT HISTORY………………………………………………….21
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 3 of 21
1. INTRODUCTION This document is the design specification for the CS22120 group project.
1.1 Purpose of This Document
This document will provide an in-depth specification of the project; including a
decomposition, description and interface description as well as a detailed
design of the entire project. This will aid in understanding how the program
works and will be of use for maintenance in the future.
2.1 Scope
This document supports the general documentation standards laid down for
CS22120 group projects [1]. This document also supports the outline structure
provided in SE.QA.05, Design Specification Standards [2]. This document
should be read and thoroughly understood by all team members and anybody
wishing to understand the workings of the program deeper.
1.2 Objectives
This objectives of this document are:
● To give a decomposition description of the program, describing its
significant classes and how these fulfil the functional requirements
given ● To give a dependency description of the program using component
diagrams ● To give interface descriptions of every class used in the program ● To provide a detailed design of the program, using sequence diagrams
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 4 of 21
2. DECOMPOSITION DESCRIPTION 2.1 Programs in System
This program is a virtual version of the Buccaneer board game. It records all
necessary information and displays it in a GUI using JavaFX. Most of the
calculations and processes are done on the backend using Java. Its purpose
is to authentically emulate the board game, being as entertaining for the user
as the original would be.
2.2 Significant Classes
Application (Main Class):
This class initialises the backend system behind the game enabling many of
the calculations required to be made.
Gui:
This class contains the graphical elements of the game. This means that this
class represents the board game and what it looks like at different times and
in different states.
GameBoard:
This class contains the backend objects behind the GUI, such as the players
and places of interest on the board.
Player:
The Player class keeps track of all the corresponding information for each
player. This includes where they are on the board, along with any items they
hold such as crew cards, treasure and chance cards.
Position:
The Position class represents a position on the game board for the backend
calculations.
PirateShip:
This class is the visual representation of the player’s location within the GUI.
ChanceCard:
The ChanceCard class contains information on all the chance cards within the
game, and their effects when activated.
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 5 of 21
CrewCard:
The CrewCard class contains information for each crew card within the game.
This includes their power and what colour the crew card is.
Treasure:
The Treasure class contains the data about each treasure in the game, what
they are and how much each one is worth.
FlatIsland:
The FlatIsland class contains the position of ‘Flat Island’, along with the crew
cards and treasure currently stored there. It has a similar use to the ‘Free
Parking’ within Monopoly, storing items taken from players.
PirateIsland:
The PirateIsland class contains the position of ‘Pirate Island’, along with any
crew cards stored there. It is the main location for crew within the game.
Place:
The Place class acts as a placeholder for every location within the game. All
of the locations inherit from it, simplifying the code and making it easier to
maintain.
Port:
This class contains the information on what is held in each port on the board.
This is important for the implementation of a trading function. The current
crew cards and treasure are stored as is whether the port is a home port.
TreasureIsland:
The TreasureIsland class contains the position of ‘Treasure Island’ along with
the chance card deck. It also contains information on what treasure is
currently stored.
UniqueLocations:
The UniqueLocations class reference the single position locations that are of
some importance, such as ‘Mud Bay’ and ‘Cliff Creek’. These are generally
required for the chance cards.
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 6 of 21
2.4 Mapping from Requirements to Classes
3. DEPENDENCY DESCRIPTION 3.1 Component Diagram
Requirement Classes Providing Requirement
FR1 Player Setup GameBoard, Player
FR2 Port Assignment Player
FR3 Crew Card Management CrewCard, Player, FlatIsland
FR4 Chance Card Management ChanceCard, Player
FR5 Treasure Management Treasure, Port, FlatIsland
FR6 Player Management Player, Position, FlatIsland, Port
FR7 Port Management Port
FR8 Flat Island Management FlatIsland
FR9 Board Display GUI
FR10 Game Setup GameBoard
FR11 Taking Turns GameBoard, GUI
FR12 Attacking Rules Player
FR13 Treasure Island TreasureIsland, ChanceCard
FR14 Flat Island FlatIsland
FR15 Arriving at a Port Port, GUI
FR16 Anchor Bay ChanceCard, GameBoard, Place
FR17 Detection of End of Game Port, GameBoard, Player
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 7 of 21
4. INTERFACE DESCRIPTION
4.1 Application Interface Specification
This class is the main class to start the game.
public class Application {
This is the main method running the application.
public static void main(String[] args) {
}
This method start the game.
private static void run() {
}
}
4.2 GameBoard Interface Specification
This class represent a game board and manages the state of the game. It calls the graphical user interface to display the board on the screen.
public class GameBoard {
This is a constructor for the GameBoard class.
public GameBoard(){
}
This method should run first to set up all objects and call the GUI to get player names.
public void setup(){
}
This method returns the players.
public Player[] getPlayers() {
}
This method returns a grid of positions.
public Position[][] getPositions() {
}
This method set a grid of positions.
public void setPositions(Position[][] positions) {
}
This method returns an object of a Treasure Island.
public TreasureIsland getTreasureIsland() {
}
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 8 of 21
4.3 ChanceCard Interface Specification
This class represents a chance card. A switch-case statement is used to represent different kinds of cards.
public class ChanceCard {
This is a constructor for a card. id is a number of a card.
public ChanceCard(int id) {
}
This method return the text shown on a card.
public String getDescription(){
}
This method returns a title of a card.
public String getTitle(){
}
This method shows if card is in use.
public boolean isInUse(){
}
This method activates a card.
public void activate(Player currentPlayer, Player chosenPlayer,
PirateIsland pirateIsland){
}
}
4.4 CrewCard Interface Specification
This class represents a crew card.
public class CrewCard {
This method is a constructor.
public CrewCard(boolean isBlack, int power) {
}
This method is a default constructor.
public CrewCard(){
}
This method returns a power of a card.
public int getPower() {
}
This method sets the power of a card.
public void setPower(int power) {
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 9 of 21
This method returns information if the card is black or red.
public boolean isBlack() {
}
This method changes the colour of a card.
public void setBlack(boolean isBlack) {
}
}
4.5 Treasure Interface Specification
This class represents an item of treasure.
public class Treasure {
This method is a constructor.
public Treasure(String name, int value) {
}
This methods returns a name of treasure.
public String getName() {
}
This method changes the name.
public void setName(String name) {
}
This method returns the value.
public int getValue() {
}
This method changes the value.
public void setValue(int value) {
}
}
4.6 Player Interface Specification
This class represents a player.
public class Player {
This method is a constructor for the Player class.
public Player(GameBoard gameBoard, Position position) {
}
This method changes the name of a player.
public void setName(String newName) {
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 10 of 21
This methods returns the name of a player.
public String getName() {
}
This method sets home port of a player.
public void setHome(Port home) {
}
This method returns the home port of a player.
public Port getHome() {
}
This method sets the player’s ship’s position on the board.
public void setPlayerPosition(Position newPosition) {
}
This method returns the position of a player’s ship.
public Position getPlayerPosition() {
}
This method sets the orientation of a player’s ship.
public void setOrientation(int orientation){
}
This method returns the orientation of a player’s ship.
public int getOrientation(){
}
This method tells if it’s this player’s turn now.
public boolean isTurn() {
}
This method sets a player’s turn.
public void setTurn(boolean isTurn) {
}
This method returns a treasure to trade.
public Treasure getTradeableTreasure() {
}
This method sets a treasure to trade.
public void setTradeableTreasure(Treasure tradeableTreasure){
}
This method returns a crew card to trade.
public CrewCard getTradeableCrewCard() {
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 11 of 21
This method sets a crew card to trade.
public void setTradeableCrewCard(CrewCard tradeableCrewCard){
}
This method sets the distance a player’s ship can move.
public void setDistance(int distance) {
}
This method returns distance a player’s ship can move.
public int getDistance() {
}
This method returns battle strength of a player.
public int getBattleStrength() {
}
This method returns a number of crew cards in player’s hand.
public int getCrewCount() {
}
This method returns a number of treasure on player’s ship.
public int getTreasureCount() {
}
This method adds a new crew card to player’s hand.
public void addCrew(CrewCard newCrew) {
}
This method removes and returns lowest value crew card from player’s hand.
public CrewCard removeLowestValueCrew() {
}
This method removes and returns highest value crew card from player’s hand.
public CrewCard removeHighestValueCrew() {
}
This method removes and returns an item of treasure from a ship.
public Treasure removeTreasure() {
}
This method removes and returns least valuable treasure from player’s ship.
public Treasure removeLeastValueableTreasure() {
}
This method removes and returns most valuable treasure from player’s ship.
public Treasure removeMostValueableTreasure() {
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 12 of 21
This method adds a new treasure to player’s ship.
public void addTreasure(Treasure newTreasure) {
}
This method adds a new chance card to player’s hand.
public void addChance(ChanceCard newChance) {
}
This method is used to attack another player.
public void attack(Player opponent) {
}
}
4.7 Position Interface Specification
This class represents a position on the board.
public class Position {
This is a constructor for a class.
public Position(int x, int y, Rectangle r) {
}
This is a constructor for a class.
public Position(int x, int y){
}
This method tells if a position can contain players.
public boolean isMoveable() {
}
This method sets if a position can contain players.
public void setMoveable(boolean moveable) {
}
This method returns a list of players on a position.
public ArrayList<Player> getPlayers() {
}
This method adds a player to a list of players at a position.
public void addPlayer(Player p) {
}
This method returns a rectangle to place a position on a grid with GUI.
public Rectangle getR() {
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 13 of 21
This method sets a rectangle for a position for GUI.
public void setR(Rectangle r) {
}
This method returns the x axis of a position.
public int getX() {
}
This method sets the x axis of a position.
public void setX(int x) {
}
This method returns the y axis of a position.
public int getY() {
}
This method sets the y axis of a position.
public void setY(int y) {
}
}
4.8 GUI Interface Specification
This class is used for visual representation of the game.
public class GUI extends Application {
This methods sets up a grid to display.
public void start(Stage primaryStage) {
}
This method calculates to which positions a player can move and returns them to set them to green.
public ArrayList<Rectangle> setGreen(PirateShip ship, Rectangle[][] rec,
Position[][] pos) {
}
This is a main method.
public static void main(String[] args) {
}
}
4.9 PirateShip Interface Specification
This class represents a ship for the GUI.
public class PirateShip {
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 14 of 21
This is a constructor.
public PirateShip(int sP, int o, Color c) {
}
This method return a position of a ship.
public Position getPosition() {
}
This method sets a position of a ship.
public void setPosition(Position position) {
}
This method returns a polygon with a pirate ship.
public Polygon getPirateShip() {
}
This method draws a ship.
public void makePirateShip(Color color) {
}
This method returns distance a ship can sail.
public int getSailPower() {
}
This method sets sail power of a ship.
public void setSailPower(int sailPower) {
}
This method returns an integer with orientation(1 is north, 2 north-east etc)
public int getOrientation() {
}
This method sets orientation of a ship.
public void setOrientation(int orientation) {
}
}
4.10 FlatIsland Interface Specification
This class represents a Flat Island. It extends a Place class.
public class FlatIsland extends Place {
This method is a constructor for FlatIsland class.
public FlatIsland(){
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 15 of 21
This method adds treasure to the Priority Queue of treasure.
public void addTreasure(Treasure treasureToBeAdded){
}
This method removes and returns the highest value treasure from the Priority Queue.
public Treasure getTreasure(){
}
This method adds a new crew card to the Array List of crew cards.
public void addCrew(CrewCard crewCardToBeAdded){
}
This method gives all the crew cards from the Array List to the current player.
public void takeAllCrew(Player currentPlayer){
}
This method returns the Array List of crew cards.
public ArrayList<CrewCard> getCrewArray(){
}
This methods returns the total power of all the crew card in the Array List.
public int getStoredCrewPower(){
}
}
4.11 PirateIsland Interface Specification
This class represents a Pirate Island. It extends a Place class.
public class PirateIsland extends Place {
This is a constructor.
public PirateIsland(){
}
This method adds a new crew card to a list.
public void addCrewCard(CrewCard card) {
}
This method takes a crew card from a list and returns it.
public CrewCard takeCrewCard() {
}
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 16 of 21
4.12 TreasureIsland Interface Specification
This class represents a Treasure Island. It extends a Place class.
public class TreasureIsland extends Place {
This is a constructor.
public TreasureIsland() {
}
This method adds treasure to a list.
public void addTreasure(Treasure t) {
}
This method removes a treasure with a name tName from a list and returns it.
public Treasure takeTreasure(String tName) {
}
This method add a new chance card to a queue.
public void addToDeck(ChanceCard chance) {
}
This method removes a chance card from a queue.
public ChanceCard removeFromDeck() {
}
This method returns a list of treasure.
public ArrayList<Treasure> getTreasure() {
}
}
4.13 Place Interface Specification
This class represents a place on a board.
public class Place{
This method returns a name of a place.
public String getName() {
}
This method sets a name of a place.
public void setName(String name) {
}
This method returns a position of a place.
public Position getPos() {
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 17 of 21
This method sets a position of a place.
public void setPos(Position pos) {
}
This method tells if a place can contain players.
public boolean isMovable() {
}
This method sets if a place can contain players.
public void setMovable(boolean movable) {
}
}
4.14 Port Interface Specification
This class represents a port. It extends a Place class.
public class Port extends Place {
This method tells if a port is a home port.
public boolean isHome() {
}
This method sets if a port is a home port.
public void setHome(boolean isHome) {
}
This method adds a crew card to a list.
public void addCrew(CrewCard nCards) {
}
This method adds treasure to a list.
public void addTreasure(Treasure nTreasure) {
}
This method is used for trading treasure.
public void tradeTreasure(Player p, CrewCard crew) {
}
This method is used for trading crew.
public void tradeCrew(Player p, Treasure treas) {
}
}
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 18 of 21
4.15 SortQueue Interface Specification
This class is a comparator for a priority queue of treasure in Flat Island.
public class SortQueue implements Comparator<Treasure>{
This method compares treasure’s value to sort if from highest to lowest.
public int compare(Treasure treasureOne, Treasure treasureTwo){
}
}
4.16 UniqueLocations Interface Specification
public class UniqueLocations {
public Position getPos() {
}
}
5. DETAILED DESIGN
5.1 Sequence Diagrams
5.2 Significant Algorithms
ChanceCard class: No complex algorithms
CrewCard class: No complex algorithms
Treasure class: No complex algorithms
Application class: No complex algorithms
GameBoard class:
- setUpPlayers – creates 4 new players, uses array to store identity.
- setUpPositions – creates the positions of the squares on the ‘board’. Uses two for loops and a
20 by 20 array to set up.
- setUpPlayerPositions – sets the positions for each of the players in the game. Using arrays to
match the board, positions are entered (x and y coordinates) and is uniquely assigned to a
player.
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 19 of 21
Player class:
- updateStrength – adjusts the power number the player has based on the current hand of cards.
This is done by checking how many black cards and how many red cards the player has, then
finds the difference.
- removeLowestValueCrew – remove the crew card of the lowest value. Checks each card to find
lowest value, then removes. Followed by updating of distance and strength numbers as they
would have changed.
- removeHighestValueCrew – similar to above, finds highest value crew card and removes from
pack. Then calls for updating of the strength and distance numbers.
- removeLowestValueTreasure – remove the treasure card of the lowest value. Checks each card
to find lowest value, then removes.
- removeHighestValueTreasure – similar to above, finds highest value treasure card and removes
from pack.
- Attack – checks current players battle strength and the opponent players battle strength,
compares using various if statements and declares winner.
- AwardBattleWinner – checks if the loser has any treasure to give, if so then piece of treasure
removed and given to winner.
Position class: No complex algorithms
Flat Island class: No complex algorithms
Pirate Island class:
- setUpCrewCards – generates 8 crew cards for pirate island with random numbers (between 1
and 13) and random colour (red or black) and stores in ArrayList.
Place class: No complex algorithms
Port class:
- tradeTreasure
- tradeCrew
SortQueue class: No complex algorithms
TreasureIsland class:
- TreasureIsland – creates Arraylist to store treasure on treasureIsland, creates second arraylist
for chance cards. Then fills the arraylists with correct items and values. Shuffle function then
shuffles the cards, different order each time.
- takeTreasure – first ensures there is one or more items in treasure chest, then will give the item of treasure that matches the name of treasure searched when calling the function.
UniqueLocations class: No complex algorithms
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 20 of 21
5.3 Significant Data Structures
positions 2d array – stores the position/location as x and y coordinates of either a place, port or player.
Player array – stores the number of players in the game.
crewCards ArrayList – holds the crew cards of a player.
booty ArrayList – holds the treasure of a player.
chanceCards ArrayList – holds the chance cards picked up by a player.
Moveable Boolean – is important, must be assigned to places and ports to ensure they are not
moveable. Players are moveable.
Design Specification. Version 1.4 (Release)
Aberystwyth University / Computer Science Page 21 of 21
REFERENCES
[1] Software Engineering Group Projects: General Documentation Standards. C.J.
Price, N.W. Hardy, B.P. Tiddeman. SE.QA.02. 2.1 Release
[2] Software Engineering Group Projects: Design Specification Standards. C.J. Price.
SE.QA.05. 2.1 Release
DOCUMENT HISTORY
Version CCF No. Date Changes Made to Document
Changed By
1.0 N/A 26/03/17 N/A – Original
Document
AJR
1.1 N/A 28/03/17 Added the introduction section. Added
references.
AJR
1.2 N/A 31/03/2017 Added component diagram(3.1). Added
interface descriptions(4)
IZS
1.3 N/A 04/04/2017 Added sections 5.2 and 5.3
JAH
1.4 N/A 05/05/2017 Changed the header/footer, filled out the contents page,
checked against QA document
AJR