Subroutine anaylsis Flashcards

1
Q

What data type does the GetIndexOfSquare subroutine return?

A

Int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What parameters does the GetIndexOfSquare subroutine take in?

A

int SquareReference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the squareReference variable?

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is squareReference calculated?

A

Row*10 + column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Is Squarerefernce Internal or user facing and why?

A

It is user facing because SR is how the user interacts with the program by entering the square row and then the column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the returned by GetIndexOfSquare?

A

An int value that is the index of the square in the list of squares.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How are the squares mapped to the List board?

A

The squares are mapped sequentially and go from left to right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the GetIndexOfSquare subroutine?

A

To convert a square location to its index the the List board.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does the GetIndexOfSquare sub work?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the limitations of the board size?

A

The board cannot have more than 9 columns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the parameter for the CheckSquareInbounds sub?

A

int squareReference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the return value for CheckSquareInbounds?

A

A bool value that realates to whether the SR passed is is a valid square or not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of the CheckSquareInbounds sub?

A

It is to verify if the SR inputed by the user is a square that exists on the board

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does the CheckSquareInbounds sub work?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the return value for CheckifGameOver?

A
  • Bool value
  • relates to whether the game has finished or not
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How does the CheckifGameOver sub work?

A

It checks each sqaure for the following:
* If the current square is a kotla and if it is occupied by the opposing players mirza; if true then return true;
* If the current square contains a mirza and who it belongs two
if true it sets the playerhasmirza value to true
* The subroutine returns the Nand value of p1mirza and p2mirza

17
Q

What are the parameters for CheckSquareIsValid?

A

int squareReference, Bool startSquare

18
Q

What is Bool startSquare?

A

A bool value that represents whether the square that is being checked is the first square or the destination square

19
Q

What is the return value of CheckSquareIsValid?

A

A Boo value that represnts whether the square that is passed is a validsquare for its given purpose. e.g if the selected square can be a start square

20
Q

How does CheckSquareIsValid work?

A
  • It first checks if the square is in bounds.
  • If not then false is returned
  • then it checks if there is a piece occupying the square. If the square is empty then it can not be a start square and vice versa
  • if the square is occupied by a piece that belongs to the current player it can only be a start square
  • if the square is occupied by a piece that belongs to the other player then it can not be a start square
21
Q

What is the purpose of createBoard?

A

To create the board for the game

22
Q

How does CreateBoard work?

A
  • It works by using a nested for loop with limits to the number of rows || columns depending on the loop to check which squares are to whose kotlas.
  • When these squares are found they are assigned to each player
  • every other square is just a normal square
  • The squares are then added to the list
23
Q

What is the parameter for CreateRyottMoveOption?

A

int direction

24
Q

What is the direction variable

A

Direction is an int value that specifies what way up the board a peice should move. Positive is going from top to bottom so the direction for p1 is 1

25
Q

What is the return value for CreateRyottMoveOption?

A

It is moveOption (a list of possible moves)

26
Q

What is a moveoption object?

A

moveOption is a list of possible moves that an option can make

27
Q

What is the move object?

A

Move is like a vector as it consists of a row change and column change

28
Q

What is the purpose of CreateRyottMoveOption?

A

To get a list of all possible moves for a ryott.

29
Q

How does CreateRyottMoveOption work?

A
  • A new moveoption is instantiated
  • Then each possible move that a ryott can make is added to the moveoption list
30
Q

What is the parameter for SameAs?

A

Player Aplayer

31
Q

What is the return value for SameAs?

A

A bool value that represents whether the player that is passed in is the same as the player that calls the sub

32
Q

How does SameAs work?

A

It checks to see if the player that is passed as an argument has the same name as the player that calls the sub.
If they are the same then true is returned

33
Q

What are the parameters for CheckIfThereIsAMoveToSquare?

A

Int StartSquareReference
Int FinishSquareReference

34
Q

What is the return value of CheckIfThereIsAMoveToSquare?

A

A bool value that represents whether there is a move to the finishSquare

35
Q

How does CheckIfThereIsAMoveToSquare work?

A
  • It works out what the row and column are for the start and finish square
  • It then checks every possible move to see if it will land on the finishsquare
  • it does this by adding the current moves row and column change to start row and column and checks if it is equal to the finish row and column
  • if equal then true is returned if not then false is returned