CS3157
Fall 2002
Homework #2
due Wed Oct 2, by 6AM (electronically)
EXTENDED TO MON OCT 7, 6AM

goal.
The goal of this assignment is to solidify your command of C, including advanced topics such as file I/O, structs and typedefs.

This assignment is worth 15 points (out of 110 this semester). Distribution of points is indicated below.

One component of the educational game you are building will involve data collection. This means things like a username and password for each user of your game, usage data (i.e., which portions of the knowledge domain they've touched) and performance data (i.e., an indication of their grasp of the knowledge they've been exposed to). Taken together, this is called a student profile.

In my flashcard example from hw#1, the knowledge domain is the US states and capitals. So the usage data for each user would be those state/capital pairs which the user has been quizzed on. The user's performance data could be a simple statistic: for each state, the percentage of times s/he has correctly named the capital; and for each capital, the percentage of times s/he has correctly named the state. You'll also need an initial value (maybe -1 in this case) to indicate that the user has not yet been quizzed about a given state/capital or capital/state.

Your job for hw#2 is to write, in C, the code necessary for maintaining a data file of student profiles. Even if you only have one customer, you should be able to generalize and allow more than one person to play your game. For each user, you need to store the following:

This data will be stored in a file (text or binary, your choice), and you must write code that will perform the following operations on the data in that file:

FIRST, print out the timesheet and keep track of how much time you spend doing the tasks outlined below.

1. design.(3 points)
You need to begin with a design document. Include in the design document a description of the data you are going to store and how you are going to store it. If you make any changes to the game as described in your first homework, you must document these changes here.
This documentation should be 1-2 pages, 10-point font. It must be complete -- so you need to be CLEAR and CONCISE. You MUST print out the documentation and bring it to class on the due date.

2. define your data structures.(2 points)
You must define a data structure to store the student profile (hint: use typedef and struct) and you must have a way to store profiles for multiple students (hint: use an array). Create these definitions in a header file (i.e., a .h file). For example, you could call it profile.h.

3. build an administrator program.(5 points total: 3 points for the data manipulation file and 2 points for the user interface file, as described below)
You need to write a simple program that allows an "adminstrator" to get access to your file of student profiles. Your program must be menu-driven* and contain the following options:

*By menu-driven, I mean that you should display a menu of the options above (plus an option to quit the program), prompt the user to select an option, read the user's option and process it.

This task involves creating two source files:

  1. data manipulation file: This file will contain a separate function to perform each of the options shown above. You must include here functions that read from and write to the file of student profiles, and you need to call the "read" function to initialize the data array and the "write" function when you make changes to the data array. Since this file contains only functions that manipulates the data structure declared, it should be the same name as the header file you created in the previous step, but with a .c extension instead. So in our example, the file would be called profile.c.
  2. user interface file: This file will contain the "user interface": a main() and the function(s) for displaying the menu, prompting the user for input, reading the user's input and processing the input. The processing steps must call the functions from the file created above (e.g., profile.c).

4. connect the data file to the game.(3 points)
Modify your hw#1 program to use the data file you've just created. You'll need to include the header file with the data structure definition(s) (e.g., profile.h). You'll need to link it with the file that contains the data manipulation functions (e.g., profile.h).

Note: You may need to expand and/or change the game and/or the hw#1 program to accommodate the data collection. This is fine, just be sure to document these changes in your design document (step 1).

5. write a compile and link script.(1.5 point)
Write a simple script file that will automatically compile and link each of the two programs you wrote for steps 3 and 4.
INSTRUCTIONS ARE HERE.

6. submit.(0.5 points)
You need to submit your program in two ways: electronically and hard copy. There is no partial credit here -- if you don't follow the submission instructions, you lose all the points for this section.

  1. electronically
    Follow the submission instructions.
  2. hardcopy.
    (1) Print out the homework template cover page and fill it out.
    (2) Print out the timesheet and fill it out.
    (3) STAPLE the cover page, timesheet and hardcopy of your documentation together.
    (4) Make sure your name and CUNIX ID are on all the papers you hand in!
    (5) Bring all this to class on the day the assignment is due and deposit it in the homework box at the front of the classroom within the first 5 minutes of the class (by 1.15pm).