Lab 9

Classes

There are two problems this week. One is a modification of last week's assignment. Use multiple files which includes a header file and provide a make file in both cases.

1. Bar Code Checker. Do Problem #13, textbook page 607-8. Name the program Lab9_BarCodes.

2. Robot World with Classes: After completing the Robot World program from the Lab 8, redesign it using classes instead of structures. Name the program Lab9_RobotWorld_Classes. Restructure your project from the previous lab assignment such that the information about robots and shots is located in classes. If you have not done the robot assignment of the previous lab, contact the lab assistant and get help to finish it.


Although the problem is slightly different, you might want to look at the header file posted for the other section. It is
located here. You might also wish to look at the basic outline provided in the other section's description. for the Battleship problem which is reproduced below.


From the other section's description:

1. Battleship with Classes. Create a project titled Lab9_BattleshipClasses. Restructure your project from the previous lab assignment such that the information about battleships and shots is located in classes.

Hint: Your main function outline should be as follows:

declare an object of class fleet
call deploy() method on it
loop while method operational() returns true. Inside the loop,

declare an object of class location,
invoke inputShot() on it to get the location of the user's shot,
pass this object to fire() method of your fleet object,
analyze the return value of this method to report whether the shot was a hit or a miss.

You are free to modify the header file as you see fit. For example, you may consider defining a few simple functions inline. The operation of your program should remain as in the previous lab assignment.

Make sure your programs adhere to proper programming style. Submit your projects to the subversion repository. Do not forget to verify your submission on the web.


REMEMBER: The above problem is not quite the same as ours, but it is similar and you should be able to modify the material provided. Programmers often have to modify other peoples' code so this provides you with some experience doing this.