Project 6
Number Guessing
Guessing numbers is pretty simple, but what happens when the person giving you clues isn’t telling the truth? In this project, you’ll write code in which the computer picks a number and the player tries to guess the number in the fewest moves.
This project introduces a new way to start to organize your code. You’ll learn more about objects and classes, which give you a way to store data and methods together in a way that helps you think more clearly about the problem you’re trying to solve. In the number guessing game, you’ll start by simply splitting the program into the player part and the game part.
Organizing a New Project
You’ll use Atom to create and edit your source code, and you’ll store this project in a single Ruby file. You’ll use the terminal program to run and play the number guessing game.
Follow these steps to set up your source code directory and file for this project:
- Start your terminal program and enter the development folder:
$ cd development
- Create a new directory for this project:
$ mkdir project06
- Move in to the new directory:
$ cd project06
- Start Atom by double-clicking its icon.
- Create a new source code file by choosing File ⇒ New ...
Get Ruby For Kids For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.