Introducing the Practice1:52 with Jay McGavren
Let's practice some basic Ruby to make sure that everything you've learned so far sticks. We'll review variables, as well as simple input and output.
[MUSIC] 0:00 Let's practice some basic Ruby to make sure that everything that you've learned 0:04 so far sticks. 0:08 We'll review variables, as well as simple input and output. 0:08 If you're not familiar with these topics, 0:12 check the Teacher's Notes attached to this video for links where you can learn more. 0:14 We're going to ask you to build a simple Ruby program. 0:18 Your program will play a fill-in-the-blank word game with the user. 0:22 You'll prompt them for a noun, a verb, and so forth, just like this. 0:25 So please enter a verb, jump. 0:30 Please enter a noun, desk. 0:31 Please enter an adjective. 0:33 Let's say, quick. 0:35 And another noun. 0:36 Let's say, can. 0:38 Then you'll use those stored words to fill in blanks in several sentences and 0:39 print the completed sentences out. 0:43 The resulting story will probably sound a little silly, and 0:45 that's exactly the point of the game. 0:48 It's pretty simple but it combines several fundamental programming steps. 0:49 The formatting on your printed story may look a little strange. 0:54 Don't worry about that while you're coding your solution. 0:57 When I show you my solution, I'll also show you a new method you can go back and 0:59 add to your program to clean up the output. 1:03 I've attached a workspace to this video, 1:06 which includes a game.rb starter file with instructions as Ruby comments. 1:08 You should open the workspace now. 1:12 You can either use our in-browser editor, or you can choose Download Workspace from 1:15 the File menu, if you have Ruby installed on your computer. 1:19 Write your code in the game.rb file and save your work. 1:23 Then, switch to the terminal and type ruby game.rb. 1:26 That will run your completed game. 1:31 The game should begin prompting for words and print your story when it's done. 1:33 I've linked to some videos in the Teacher's Notes, 1:38 which you can refer to if you get stuck. 1:40 After you've written your program, 1:41 you can proceed to the next video where you can compare my solution to yours. 1:43 Ready? 1:47 Get started on your program. 1:48 I'll show you my version in the next video. 1:49
You need to sign up for Treehouse in order to download course files.Sign up