CS 170 - Programming Assignment #2

Due Thursday, February 16, 2017 at 10:00 pm

Observations: Many students are forgetting that arrays in C/C++ are zero-based, meaning, if you have an array of 5 boats, you'd better only index that array with 0 through 4. Students are indexing that array using the BoatID (1 through 5), which is the cause of 99.9% of the problems. Remember, overwriting an array means your program is undefined (broken), which (unfortunately) usually means it will work for you on your machine with simple tests, but won't work for me when I test it. The same is true when doing bounds-checking to see if the boat or shot is outside of the array (ocean). So, please, please, please pay attention to the details when indexing an array.

The sample driver is just that, a sample. Just because you pass all of the tests in that simple driver doesn't necessarily mean your code is perfect. Several people had incorrect output or crashes because they failed to check the coordinates of the boats or shots correctly. The problem is that they failed to check if the coordinates were negative. They were checking that the coordinates were less than the x and y dimensions, but they didn't check to make sure the coordinates weren't less than 0. Many students failed to do this. Double-check your checks!

Information

Additional Sample Program Runs

Be sure that you test your code with this driver as well, especially the 8x12 board. YOU HAVE BEEN WARNED.

GUI Driver

After completing this assignment, you will have the "logic" to create a simple game like this one.

Download the executable     No installation necessary. Just copy to your hard drive and run it.