project1 soln

project1 soln - Spring 2009 CS 32 Programming Assignment 1...

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

View Full Document Right Arrow Icon
Spring 2009 CS 32 Programming Assignment 1 Attack of the Robots Time due: 9:00 PM Tuesday, April 7 The appendix to this document is the specification of the last CS 31 project from a previous quarter. We will provide you with a correct1 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 all the headers it needs and does not include the non-standard headers it doesn't need. (For example, don't include Player.h if it's not necessary, but it's OK if a file unnecessarily includes <string>.) Each header file must have include guards. Now what about the manifest constants and the CellStatus and Dir enumeration? 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++ 2008 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 these updated robots.exe and updated minirobots.exe programs, you'll see they have implemented 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.
Background image of page 1

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

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

This note was uploaded on 01/24/2012 for the course CS CS 32 taught by Professor Mojavi during the Spring '08 term at UCLA.

Page1 / 4

project1 soln - Spring 2009 CS 32 Programming Assignment 1...

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

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