[SOLVED] CPSC 2150 - Homework 3

35.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (2 votes)

Introduction:

For this assignment we will continue to work on our Extended Tic-Tac-Toe  game, but we will be adding new requirements. The old requirements are still required, unless they are replaced by a requirement in this prompt.

New Implementation

You will need to provide a new class called GameBoardMem that will extend AbsGameBoard which implements the IGameBoard interface. This new implementation will be slower, but more memory efficient.

To represent the game board you will use a Map.  Map is another Generic collection that uses a key – value pair. The key field of our Map will be a Character that represents the player, so each player will get their own entry in the Map. The Value associated with that player will be a List of BoardPositions that the player occupies on the board. If a player has not placed a token yet, then there will be no key or List in the Map to represent that player. Do NOT create a key for the blank space with a List of BoardPositions that are blank. The memory efficiency of this implementation comes from the fact that and empty board does not use up any space in memory. When a player adds their first token, then you add the key for that player and a List with that BoardPosition in it. As more tokens are added by a player, you add the BoardPosition onto the List for that player.        There is a video available on Canvas that discusses some Maps in more detail, and discusses how to declare and work with Maps. It describes many useful methods in the Map class as well.                While this may seem like a lot of work to create this new implementation, remember that your new implementation only needs to provide code for your primary methods, and the constructor. All of your secondary methods can be handled by default implementations in the interface, and toString is provided by AbsGameBoard. However, we will want to override one of the default implementations.     While this representation of a game board will be more memory efficient, it will be slower. With a 2D array, if we want to know what is in row 2, column 3, we can access that position in the array directly. However, we can no longer do that with our data representation in a Map. If we want to know what’s at row 2, column 3, we need to look in each key-value entry in the Map. If row 2, column 3 exists in the List (our value in the map) then the player who’s character is the key is at that position. If the position does not exist in any list, then the space is blank.

Now consider if instead of wanting to know what’s at position 2, 3 we just need to know if ‘X’ is at position 2, 3. Now instead of needing to check every List, we just need to check the List that has

‘X’ as it’s key. This is why our interface has the two separate methods whatsAtPos and isPlayerAt. When we were using a 2D array, they were implemented in the same way, but now that we are using a Map, the implementations are quite different. Our interface didn’t care about how it was implemented, we just knew that asking “what’s at this position?” and “is X at this position?” are different questions, and should be asked in different ways. This means we can override the default isPlayerAt method in our GameBoardMem implementation to make a more efficient implementation for that particular data structure. After doing so, make sure your code is making sure to call isPlayerAt when it is appropriate to do so, and not just rely on whatsAtPos.

 

Example Board

Consider the following Board:

 

| 0| 1| 2| 3| 4| 5| 6| 7| 8|

0|  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |

2|  |  |  |X |X |X |O |  |  |

3|  |  |  |  |T |  |T |  |  |

4|  |  |  |O |O |T |  |  |  |

5|  |  |  |  |  |  |W |  |  |

6|  |  |  |  |  |  |W |  |  |

7|  |  |  |  |  |  |  |  |  |

 

In our implementation from Homework 2, this board would be represented in memory as an 8 by 8 2D array of characters. Blank spaces in the board are represented by that position in the array containing a ‘ ‘ character. While we can quickly access any place on the board by jumping to that index in the array, our board takes a lot of memory because it is always storing 64 characters. Now consider what this board would look like in our memory efficient implementation.

In our memory efficient implementation we would have a Map<Character,

List<BoardPostion>> with our key being the player that represents a character. We currently only have 4 players (X, O, T, W) so those will be the only keys in our Map. For our 4 players, we will have keys and matching Lists. So if we asked our Map to return the value for key W it would return a List of BoardPositions (Row, Column) with <(5,6), (6,6)> in it. As player W places more markers, we can add more BoardPostions to the List.

 

Our Key Value pairs for this board would be as follows:

Key Value
X <(2,3), (2,4), (2,5)>
O <(4,3), (4,4), (2,6)>
T <(3,4), (4,5), (3,6)>
W <(5,6), (6,6)>

 

 

 

Contracts and Comments

All methods (except for the main) must have preconditions and post-conditions specified in the

Javadoc contracts. All methods (except for main) must also have the params and returns specified in the Javadoc comments as well. You must include a complete interface specification in IGameBoard, and write the contracts not included in the interface specification in the GameBoard class. You must provide correspondences and invariants in your GameBoard class.

You code must be well commented. The Javadoc comments will only be enough for very simple methods. Remember, your comments will help the grader understand what you are trying to do in your code. If they don’t understand what you are trying to do, you will lose points.

 

Input and Output

Remember, the TAs will be grading this assignment using scripts as much as possible. You can make this easier on them by using the correct format for input and output. If their scripts don’t work because you do not follow the input and output standards a few things will happen:

  1. Grading and feedback will take longer
  2. The TA will be mad at you, which you never want when they are grading your assignment
  3. The TA will have to spend more time manually using and inspecting your code, which means they are more likely to find minor issues and deduct points.
  4. You will lose points for not following the instructions.

 

This is what my input and output looks like. Notice how it handles more than 10 columns, Notice that row and column are asked for separately and in that order.

 

 

Requirements Analysis

Fully analyze the requirements of this program. Express all functional requirements as user stories. Remember to list all non-functional requirements of the program as well.

Design

Create a UML class diagram for each class and interface in the program. Also create UML Activity diagrams for every method in your GameScreen class and every method in your GameBoard or GameBoardMem class . If a method is defined as a default method in the interface, you need to update the diagrams to remove any mention of the 2D array or other private data of the GameBoard class, and instead refer to primary methods. If a method is provided only as a default method in the interface you only need to provide an Activity Diagram for the default method, you do not need to include the diagram for each implementation as well. If you provide a default method in the interface, but override it in the implementation you need to include an activity diagram for each method. Your diagram for toString should not reference private data since it will exist in the abstract class.

 

Sample Input and Output:

How many players?

12

Must be 10 players or fewer How many players?

1

Must be at least 2 players How many players?

4

Enter the character to represent player 1 x

Enter the character to represent player 2 x

X is already taken as a player token! Enter the character to represent player 2 o

Enter the character to represent player 3 t

Enter the character to represent player 4

F

How many rows?

0

Rows must be between 3 and 100

How many rows?

150

Rows must be between 3 and 100

How many rows?

12

How many columns?

0

Columns must be between 3 and 100

How many columns?

150

Columns must be between 3 and 100

How many columns?

15

How many in a row to win? 5

Would you like a Fast Game (F/f) or a Memory Efficient Game (M/m? g

Please enter F or M

Would you like a Fast Game (F/f) or a Memory Efficient Game (M/m? m

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player X Please enter your ROW

4

Player X Please enter your COLUMN

7

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |  |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player O Please enter your ROW

6

Player O Please enter your COLUMN

2

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |  |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |  |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player T Please enter your ROW

13

Player T Please enter your COLUMN

17

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |  |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |  |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

That space is unavailable, please pick again

Player T Please enter your ROW

8

Player T Please enter your COLUMN

5

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |  |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |  |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player F Please enter your ROW

8

Player F Please enter your COLUMN

8

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |  |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |  |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player X Please enter your ROW

4

Player X Please enter your COLUMN

6

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |X |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |  |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player O Please enter your ROW

6

Player O Please enter your COLUMN

3

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |X |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |O |  |  |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | 11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player T Please enter your ROW

6

Player T Please enter your COLUMN

5

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |X |X |  |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |O |  |T |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player F Please enter your ROW

4

Player F Please enter your COLUMN

8

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |  |O |O |  |T |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player X Please enter your ROW

6

Player X Please enter your COLUMN

1

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |  |X |X |F |  |  |  |  |  |  |  5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player O Please enter your ROW

4

Player O Please enter your COLUMN

5

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player T Please enter your ROW

10

Player T Please enter your COLUMN

5

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player F Please enter your ROW

5

Player F Please enter your COLUMN

8

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |  |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player X Please enter your ROW

6

Player X Please enter your COLUMN

8

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |  |  |  |  |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player O Please enter your ROW

5

Player O Please enter your COLUMN

4

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |  |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  | 11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player T Please enter your ROW

7

Player T Please enter your COLUMN

5

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |  |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player F Please enter your ROW

9

Player F Please enter your COLUMN

5

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |  |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |F |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player X Please enter your ROW

3

Player X Please enter your COLUMN

5

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |X |  |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |  5|  |  |  |  |O |  |  |  |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |F |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player O Please enter your ROW

3

Player O Please enter your COLUMN

6

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |X |O |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |  |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |F |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player T Please enter your ROW

5

Player T Please enter your COLUMN

7

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |X |O |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |T |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |F |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player F Please enter your ROW

7

Player F Please enter your COLUMN

2

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|  0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |X |O |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |T |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |F |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |F |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player X Please enter your ROW

2

Player X Please enter your COLUMN

4

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |X |  |  |  |  |  |  |  |  |  |  |

3|  |  |  |  |  |X |O |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |T |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |F |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |F |  |  |  |  |  |  |  |  |  |

10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  |

11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Player O Please enter your ROW

2

Player O Please enter your COLUMN

7

Player O wins!

0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|

0|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

1|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

2|  |  |  |  |X |  |  |O |  |  |  |  |  |  |  |

3|  |  |  |  |  |X |O |  |  |  |  |  |  |  |  |

4|  |  |  |  |  |O |X |X |F |  |  |  |  |  |  |

5|  |  |  |  |O |  |  |T |F |  |  |  |  |  |  |

6|  |X |O |O |  |T |  |  |X |  |  |  |  |  |  |

7|  |  |F |  |  |T |  |  |  |  |  |  |  |  |  |

8|  |  |  |  |  |T |  |  |F |  |  |  |  |  |  |

9|  |  |  |  |  |F |  |  |  |  |  |  |  |  |  | 10|  |  |  |  |  |T |  |  |  |  |  |  |  |  |  | 11|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

 

Would you like to play again? Y/N

y

How many players?

3

Enter the character to represent player 1 w

Enter the character to represent player 2 y

Enter the character to represent player 3 r

How many rows?

5

How many columns?

5

How many in a row to win?

3

Would you like a Fast Game (F/f) or a Memory Efficient Game (M/m? f

0| 1| 2| 3| 4|

0|  |  |  |  |  |

1|  |  |  |  |  |

2|  |  |  |  |  |

3|  |  |  |  |  |

4|  |  |  |  |  |

 

Player W Please enter your ROW

…

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.