1.1-Introductie-Programmeren

Simplify TicTacToe with methods

Difficulty: Filled Filled Filled

It is time to move on with TicTacToe. You wrote the last step improvement in exercise 9 of the Loops1 submodule. The program can place X’s in the field specified by the user. And the field is variable in size, everything adapts to the size specified by the user.

We are not going to add functionality in this assignment, we are just going to make the code more readable by moving a large piece of code to a separate method.

Assignment 1: Write a method drawBoard` that draws the board including the fields in the current situation. You call this method every time the board is drawn.

Check carefully if the program still does exactly the same.

Assignment 2: Move the code that is asking the user to specify the size of the game board to a separate method. Call the method from the main program (the run method) correctly. Check carefully if the program still does exactly the same.

Example

Example

Example