\author{COMP SCI 2ME3 and SFWR ENG 2AA4\\\\Rober Boshra}
\begin{document}
\maketitle
Specifications of battleship are split across three modules: ShipADT, BoardADT, and GameModule. GameModule provides basic access to starting a game, making a move, and checking whether the game is over. BoardADT contains the BoardT type, specifying a single board pertaining to one player and including both ship placements and hits/misses. BoardT was designed to have a sequence of ShipTs and a sequence of already hit gridcells; this is opposed to a complete two-dimensional grid. Each ship in the game is represented as an instance of ShipT with its predefined size and position on the board. A ShipT also tracks how many of its parts have been hit; however, there is no explicit tracking of which part is hit, as that is already covered by BoardT's list of hit cells.
\section*{ShipADT Module}
\subsection*{Template Module}
ShipADT
\subsection*{Uses}
N/A
\subsection*{Syntax}
\subsubsection*{Exported Constants}
MISS\_ID = $-1$\\
EMPTY\_ID = $0$\\
HIT\_ID = $1$\\
SHIPDESTROYED\_ID = $2$
\subsubsection*{Exported Types}
Gridcell = tuple of $(xpos: integer, ypos: integer)$\\
\item transition: $hits := hits || \{\langle x, y \rangle\}$
\item output: $out :=(\exists s: ShipT | s \in ss \land\langle x, y \rangle\in s.span()\Rightarrow s.hit() | \nexists s: ShipT | s \in ss \land\langle x, y \rangle\in s.span()\Rightarrow-1)$
\item exception: $exec :=\langle x, y \rangle\in hits \lor x \notin[1..\mbox{SIZE\_X}]\lor y \notin[1..\mbox{SIZE\_Y}]\Rightarrow\mbox{HITERROR})$
\end{itemize}
\noindent checkCell ($\mathit{x, y}$)
\begin{itemize}
\item output:
\begin{gather*}
out := (\exists s: ShipT | s \in ss \land\langle x, y \rangle\in s.span()\\\land\langle x, y \rangle\in hits \Rightarrow\mbox{ShipADT.HIT\_ID}
| \langle x, y \rangle\notin hits \Rightarrow\mbox{ShipADT.EMPTY\_ID}\\
| \nexists s: ShipT | s \in ss \land\langle x, y \rangle\in s.span()
\land\langle x, y \rangle\in hits \Rightarrow\mbox{ShipADT.MISS\_ID})
\end{gather*}
\item exception: $exec := x \notin[1..\mbox{SIZE\_X}]\lor y \notin[1..\mbox{SIZE\_Y}]\Rightarrow\mbox{LOCATIONERROR})$