UCLA Winter 2012 CS 32 Assignments

UCLA Winter 2012 CS 32 Assignments - Programming Assignment...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Programming Assignment 1 Attack of the Robots Time due: 9:00 PM Tuesday, January 17 The appendix to this document is the specification of the last CS 31 project from last quarter. We will provide you with a correct 1 solution to that project. Your assignment is to (1) organize the code for the solution in appropriate header and implementation files, and (2) implement a new feature. You should read the appendix now. It describes a game in which a player has to escape from robots in an arena. You will be working with this code that implements the game . Notice that it is a single file. (Just so you know, the way we tested its correctness is similar to how we'll test the correctness of the programs you write in CS 32.) Organize the code Take the single source file, and divide it into appropriate header files and implementation files, one pair of files for each class. Place the main routine in its own file named main.cpp. Make sure each file #includes the headers it needs. Each header file must have include guards. Now what about the manifest constants? Place them in their own header file named globals.h. And what about utility functions like attemptMove that are used by more than one class implementation? Place them in their own implementation file named utilities.cpp, and place their prototype declarations in globals.h. (Note that for utility functions like recommendMove that are used by only one class implementation, it would be better to declare and implement them in that class's implementation file, not in globals.h.) The Visual C++ 2010 writeup demonstrates how to create a multi-file project. From the collection of the eleven files produced as a result of this part of the project, make sure you can build an executable file that behaves exactly the same way as the original single-file program. Add a feature If you try running the updated programs (the Windows version or the Mac version of the full game, and the Windows version or the Mac version of the smaller version of the game), you'll see they have one new command you can type: h for history. This command shows you how many turns the player has been on each grid point (not counting the player's initial placement on the grid): dot means 0, a letter character A through Y means 1 through 25 times (A means 1, B means 2, etc.) and Z means 26 or more times. Your task is to implement this functionality. You will need to do the following: • Define a class named History with the following public interface: • class History • { • public: • History(int nRows, int nCols); • bool record(int r, int c); • void display() const; • }; o The constructor initializes a History object that corresponds to an Arena with nRows rows and nCols columns. You may assume (i.e., you do not have to check) that it will be called with a first argument that does not exceed MAXROWS and a second that does not exceed MAXCOLS, and that neither argument will be less than 1....
View Full Document

This note was uploaded on 04/06/2012 for the course CS 32 taught by Professor Davidsmallberg during the Winter '08 term at UCLA.

Page1 / 57

UCLA Winter 2012 CS 32 Assignments - Programming Assignment...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online