65 lines
2.3 KiB
Text
65 lines
2.3 KiB
Text
sequenceDiagram
|
|
actor User
|
|
|
|
rect rgb(204, 255, 255)
|
|
note right of User: Create a board
|
|
create participant Board
|
|
User--)Board: Board(int width, int height)
|
|
create participant CollectionElements
|
|
Board--)CollectionElements: HashMap<>();
|
|
create participant Coordinate
|
|
Board--)Coordinate: Coordinate(int minX, int minY)
|
|
Board--)Coordinate: Coordinate(int maxX, int maxY)
|
|
end
|
|
|
|
rect rgb(229, 255, 204)
|
|
note right of User: Create and add an element
|
|
create participant Element
|
|
User--)Element: Element() implement ElementInterface
|
|
User->>Board: addElement(Element element, int x, int y)
|
|
Board--)Coordinate: Coordinate(int x, int y)
|
|
Board-)Coordinate: testCoordinate(Coordinate(int x, int y)
|
|
alt coordinate are invalid
|
|
Coordinate--)Board: IndexOutOfBoundsException()
|
|
Board--)User: IndexOutOfBoundsException()
|
|
else coordinate are valid
|
|
Board->>CollectionElements: put(Element element, Coordinate coordinate)
|
|
end
|
|
end
|
|
|
|
rect rgb(255, 204, 204)
|
|
note right of User: Get elements of a coordinate
|
|
User-)Board: getElements(int x, int y)
|
|
Board-)Coordinate: testCoordinate(Coordinate(int x, int y)
|
|
alt coordinate are invalid
|
|
Coordinate--)Board: IndexOutOfBoundsException()
|
|
Board->>User: IndexOutOfBoundsException()
|
|
else coordinate are valid
|
|
Board-)CollectionElements: Get elements at given coordinate
|
|
CollectionElements--)Board: return elements
|
|
Board->>User: return elements
|
|
end
|
|
end
|
|
|
|
rect rgb(255, 204, 255)
|
|
note right of User: Remove an element
|
|
User-)Board: removeElement(Element element)
|
|
Board-)CollectionElements: containsKey(Element element)
|
|
alt element not in CollectionElements
|
|
CollectionElements--)Board: return false
|
|
Board--)User: return false
|
|
else element in CollectionElements
|
|
CollectionElements--)Board: return true
|
|
Board-)CollectionElements: remove(Element element)
|
|
Board--)User: return true
|
|
end
|
|
end
|
|
|
|
rect rgb(204, 204, 255)
|
|
note right of User: Clear coordinate
|
|
User-)Board: clearCoordinate(int x, int y)
|
|
Board->>Board: getElements(int x, int y)
|
|
note over Board: see Get elements of a coordinate
|
|
Board->>Board: removeElement(Element element)
|
|
note over Board: For each element found, see Remove an element
|
|
end
|