CS101 Lab Activity 10

Objectives

1. Requirements Specification (Problem Definition)

In this lab, you're going to design a Hangman game. The game works as follows:

Download the file named hangdemo from the directory ~cs101ta/lab10 into your home directory (use the unix cp command). Open up a unix terminal  and run the demo program hangdemo (At the Unix prompt type: hangdemo). Watch how the demo program works. You're going to write a similar program.

2. Analysis---Refine, Generalize, Decompose the problem definition

  We will give you the skeleton code in hang.c that includes the steps that you need to go through in your program (see step 4. Implementation below). But of course, you can start to write the program from scratch if you prefer. You should consider using the following functions in your program:


3. Design---Develop Algorithm

The complete flow-chart for the program is shown below.
lab10 first flow chart

second flow chart
third flow chart


4. Implementation --- Write the "Program" (Code)

Download the Eclipse project named lab10.zip (or you can download the C file hang.c ).You have to import this project into your Eclipse and begin adding your code into it. To do so, go to File, Import..., and then select 'Existing Projects into Workspace' from 'General'. Next, make sure the 'Select archive file' radio button is selected. And, Browse for 'lab10.zip'. Click on 'Finish' button, expand the newly exported project, and locate the file 'hang.c'.



5. Run the code

Save to compile your program. Note that whenever you save your source file, the compiler is run. Any compile errors are shown under the "problems" tab at the bottom of the screen and highlighted in red. If there are no errors, your source code is automatically compiled into an executable file. To run a program in Eclipse you must create another 'launch configuration' as you did in previous labs. That is, click on the black down arrow of the run button and select the binary you want to run, or click run..., double click on C/C++ application, and click Search Project. Once you've created the launch configuration, you can just select that launch configuration from the run button pull-down menu. To see a demo of how your program should work download hangdemo  (right-click and choose "Save Link Target As" and name it hangdemo without any extension.). Run this program by typing

   hangdemo

at the Unix prompt (Go to Applications, Utilities, Terminal to open a Unix prompt).

Make sure your program works properly before you proceed to the next step. 

After you've completed your program, show it to your TA and get his/her signature.