Skip to content

Commit

Permalink
rearrange
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jul 12, 2021
1 parent 9d171fe commit f52b77c
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
18 changes: 18 additions & 0 deletions crystal/conditionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,23 @@

![](examples/conditionals/default.cr)

## Exercise: Number Guessing game - level 0
{id: exercise-number-guessing-game-0}

Level 0

* Create a file called `number_guessing_game_0.cr`
* Using the random module the computer "thinks" about a whole number between 1 and 20.
* The user has to guess the number. After the user types in the guess the computer tells if this was bigger or smaller than the number it generated, or if it was the same.
* The game ends after just one guess.

Level 1-

* Other levels in the next chapter.

## Solution: Number Guessing game - level 0
{id: solution-number-guessing-game-0}

![](examples/game/number_guessing_game_0.cr)


69 changes: 0 additions & 69 deletions crystal/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,73 +425,4 @@ echo %ERROR_LEVEL%
* See the [Legal drinking age](https://en.wikipedia.org/wiki/Legal_drinking_age) list.
* Don't worry if this seems to be too difficult to solve in a nice way. We'll learn more tools to improve.

## Exercise: Number Guessing game - level 0
{id: exercise-number-guessing-game-0}

Level 0

* Create a file called `number_guessing_game_0.cr`
* Using the random module the computer "thinks" about a whole number between 1 and 20.
* The user has to guess the number. After the user types in the guess the computer tells if this was bigger or smaller than the number it generated, or if it was the same.
* The game ends after just one guess.

Level 1-

* Other levels in the next chapter.

## Solution: Number Guessing game - level 0
{id: solution-number-guessing-game-0}

![](examples/game/number_guessing_game_0.cr)

## Exercise: Number guessing game
{id: exercise-number-guessing-game}

Level 0

* Create a file called `number_guessing_game_0.cr`
* Using the random module the computer "thinks" about a whole number between 1 and 20.
* The user has to guess the number. After the user types in the guess the computer tells if this was bigger or smaller than the number it generated, or if was the same.
* The game ends after just one guess.

Level 1

* Create a file called `number_guessing_game_1.cr`
* The user can guess several times. The game ends when the user guessed the right number.

Level 2

* Create a file called `number_guessing_game_2.cr`
* If the user hits 'x', we leave the game without guessing the number.

Level 3

* Create a file called ``number_guessing_game_3.cr`
* If the user presses 's', show the hidden value (cheat)

Level 4

* Create a file called `number_guessing_game_4.cr`
* Soon we'll have a level in which the hidden value changes after each guess. In order to make that mode easier to track and debug, first we would like to have a "debug mode".
* If the user presses 'd' the game gets into "debug mode": the system starts to show the current number to guess every time, just before asking the user for new input.
* Pressing 'd' again turns off debug mode. (It is a toggle each press on "d" changes the value to to the other possible value.)

Level 5

* Create a file called `number_guessing_game_5.cr`
* The 'm' button is another toggle. It is called 'move mode'. When it is 'on', the hidden number changes a little bit after every step (+/-2). Pressing 'm' again will turn this feature off.

Level 6

* Create a file called `number_guessing_game_6.cr`
* Let the user play several games.
* Pressing 'n' will skip this game and start a new one. Generates a new number to guess.

## Solution: Number guessing game
{id: solution-number-guessing-game}


![](examples/game/number_guessing_game_1.cr)

![](examples/game/number_guessing_game_2.cr)

54 changes: 53 additions & 1 deletion crystal/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
![](examples/loops/loop.cr)


## loop controls
## loop controls (next, break)
{id: loop-controls}
{i: next}
{i: continue}
Expand All @@ -28,3 +28,55 @@
{i: until}

![](examples/loops/until.cr)

## Exercise: Number guessing game
{id: exercise-number-guessing-game}

Level 0

* Create a file called `number_guessing_game_0.cr`
* Using the random module the computer "thinks" about a whole number between 1 and 20.
* The user has to guess the number. After the user types in the guess the computer tells if this was bigger or smaller than the number it generated, or if was the same.
* The game ends after just one guess.

Level 1

* Create a file called `number_guessing_game_1.cr`
* The user can guess several times. The game ends when the user guessed the right number.

Level 2

* Create a file called `number_guessing_game_2.cr`
* If the user hits 'x', we leave the game without guessing the number.

Level 3

* Create a file called ``number_guessing_game_3.cr`
* If the user presses 's', show the hidden value (cheat)

Level 4

* Create a file called `number_guessing_game_4.cr`
* Soon we'll have a level in which the hidden value changes after each guess. In order to make that mode easier to track and debug, first we would like to have a "debug mode".
* If the user presses 'd' the game gets into "debug mode": the system starts to show the current number to guess every time, just before asking the user for new input.
* Pressing 'd' again turns off debug mode. (It is a toggle each press on "d" changes the value to to the other possible value.)

Level 5

* Create a file called `number_guessing_game_5.cr`
* The 'm' button is another toggle. It is called 'move mode'. When it is 'on', the hidden number changes a little bit after every step (+/-2). Pressing 'm' again will turn this feature off.

Level 6

* Create a file called `number_guessing_game_6.cr`
* Let the user play several games.
* Pressing 'n' will skip this game and start a new one. Generates a new number to guess.

## Solution: Number guessing game
{id: solution-number-guessing-game}


![](examples/game/number_guessing_game_1.cr)

![](examples/game/number_guessing_game_2.cr)

0 comments on commit f52b77c

Please sign in to comment.