Subroutine anaylsis Flashcards
What data type does the GetIndexOfSquare subroutine return?
Int
What parameters does the GetIndexOfSquare subroutine take in?
int SquareReference
What is the squareReference variable?
- A two digit number where the 1st integer is the row of the grid and the second is the column
- It references a square on the grid
How is squareReference calculated?
Row*10 + column
Is Squarerefernce Internal or user facing and why?
It is user facing because SR is how the user interacts with the program by entering the square row and then the column.
What is the returned by GetIndexOfSquare?
An int value that is the index of the square in the list of squares.
How are the squares mapped to the List board?
The squares are mapped sequentially and go from left to right.
What is the purpose of the GetIndexOfSquare subroutine?
To convert a square location to its index the the List board.
How does the GetIndexOfSquare sub work?
It works by extracting the row and the column by using using Mod and div.
It then calculates the index by : (row -1) * 10 + column-1
What are the limitations of the board size?
The board cannot have more than 9 columns
What is the parameter for the CheckSquareInbounds sub?
int squareReference
What is the return value for CheckSquareInbounds?
A bool value that realates to whether the SR passed is is a valid square or not
What is the purpose of the CheckSquareInbounds sub?
It is to verify if the SR inputed by the user is a square that exists on the board
How does the CheckSquareInbounds sub work?
It first calculates the row and column values of the SR.
IF the row value is less than 1 or greater than the number of rows then false is returned
if the column value is less than 1 or greater than the number of columns then false is returned
else true is returned
What is the return value for CheckifGameOver?
- Bool value
- relates to whether the game has finished or not