EECS 183 Labs

EECS 183 Lab 9: Debugging Classes

Lab due on your scheduled lab day (April 1-5)

Lab accepted for full credit until Tuesday, April 9, 2024, 11:59 pm Eastern

In this lab, you are debugging an incorrect solution.

You should complete this lab in small groups of about four students. For all labs in EECS 183, to receive a grade, every student must individually submit the Lab assignment.

Starter Files

You can download the starter files using this link.

IMPORTANT: For this lab, you must include all three files in a single project in Xcode or Visual Studio.

You will submit only your Picture.cpp to the autograder.

Lab Assignment

Tasks to Complete

  1. Start a new project with your IDE using the starter files according.
  2. Debug the implementations for the following functions in Color.cpp and Picture.cpp:
    • Color::isBlack() has one buggy line of code
    • Picture::countBlackPixels() has two buggy lines of code
    • Picture::drawPixel() has two buggy lines of code
    • Picture::drawRectangle() has one buggy line of code
  3. Test the functions using the test cases you are given in test.cpp.
  4. Submit your Picture.cpp to the autograder.

Debugging the starter files

IMPORTANT: We have included enough test cases in test.cpp to find all of the bugs in the starter files.

The Color and Picture classes are simplified versions of the similar Color and Graphics classes in Project 4 CoolPics. They are not the same classes!

Begin by fixing the compile error(s) in the starter files. You will need to fix bugs in Picture::countBlackPixels() before moving on to debugging the other functions. Hint: Review the functions for the Color class found in color.h.

Once you are able to run the code, view the output of the test cases provided.

Then for each function, in the order listed above:

  1. Read the RME to see what the function should do - what it Requires, Modifies, and the Effects.
  2. Set a breakpoint at the call to the buggy function in test.cpp. For example, start by placing a breakpoint in the function testColorisBlack at the line cout << "Expected 0, actual " << blue.isBlack() << endl;
  3. Run the code and use “Step Into” to step through the buggy function in the Color or Picture class function.
  4. Step over instructions in the buggy function, one at a time. View the values for variables while debugging to find out why the function does not work correctly.
  5. Modify the statement(s) so the function will match the RME, and pass the test cases (match expected and actual output) in test.cpp.
  6. Go back to steps 1-5 as needed until the actual output matches the expected output.

How to Submit

IMPORTANT: For all labs in EECS 183, to receive a grade, every student must individually submit the Lab Submission. Late submissions for Labs will not be accepted for credit. For this lab, you will receive ten submissions per day with feedback.