Skip to content

Instantly share code, notes, and snippets.

@tylerlmz1
Created October 27, 2020 07:28
Show Gist options
  • Save tylerlmz1/0e4647e9c1499141e7406d548fc18980 to your computer and use it in GitHub Desktop.
Save tylerlmz1/0e4647e9c1499141e7406d548fc18980 to your computer and use it in GitHub Desktop.
@startuml
'''' Declarations for title, caption, etc ''''
'''' Declarations to stylize the diagram ''''
hide circle
skinparam classFontStyle bold
skinparam classAttributeIconSize 0
'''' Attributes and methods '''
class BattleshipGame {
- inputboard : ArrayList<ArrayList>
<<constructor>> BattleshipGame()
+playgame(board:board,player:player)
}
class Board {
- virtualboard : ArrayList<ArrayList>
- ships : ArrayList<ship>
- traps : ArrayList<trap>
- potions : ArrayList<potion>
<<constructor>> Board(ship:int,trap:int,potion:int)
+createboard() : ArrayList<ArrayList>
+createships(num:int)
+createtraps(num:int)
+createpotions(num:int)
+isoverlap(temp:potion) : boolean
+getship() : ArrayList<ship>
+gettrap() : ArrayList<trap>
+getpotion() : ArrayList<potion>
+getvirtualboard() : ArrayList<ArrayList>
+displayboard(board : ArrayList<ArrayList>)
}
class Player {
- live : int
- steptaken : int
- inputx : int
- inputy : int
- shipfound : int
<<constructor>> Player()
+getsteptaken() : int
+addstep()
+setlive(l:int)
+getlive() : int
+getshipfound() : int
+setshipfound()
}
class Potion {
- y : int
- x : int
- length : int
- isused : boolean
<<constructor>> Potion()
+gety() : int
+sety(y:int)
+getx(i:int) : int
+getlength() : int
+isused() : boolean
+setused()
}
class Ship {
-posx : ArrayList<Object>
-posy : int
-length : int
-sunken : boolean
<<constructor>> Ship()
+setposition(len:int)
+setsunken()
+getx(i:int) : int
+gety() : int
+getposx() : ArrayList<Object>
+issunken() : boolean
+getlength() : int
+generateposition(x:int,y:int,len:int)
}
class Trap {
- lives : int
- y : int
- x : int
- reveal : boolean
<<constructor>> Trap()
+gety() : int
+getx(i:int) : int
+revealed()
+isrevealed() : boolean
+getlive() : int
+getlength() : int
}
class ShipRevealPotion {
<<constructor>> ShipRevealPotion()
+revealship(temp:ArrayList<ship>, board:ArrayList<ArrayList>)
}
class LifeSaverPotion {
<<constructor>> LifeSaverPotion()
+ reveal()
}
class TrapRevealPotion {
<<constructor>> TrapRevealPotion()
+ revealtrap(temp:board, board:ArrayList<ArrayList>)
}
BattleshipGame "1" *-- "1" Board
BattleshipGame "1" *-- "1" Player
Board "1" *-- "20..80" Ship
Board "1" *-- "10..30" Trap
Board "1" *-- "0..18" Potion
Potion <|-- ShipRevealPotion
Potion <|-- LifeSaverPotion
Potion <|-- TrapRevealPotion
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment