EECS 183 Labs
EECS 183 Lab 9: Debugging Classes
Lab due on your scheduled lab day (November 11-15)
Lab accepted for full credit until Tuesday, November 19, 2024, 11:59 pm Eastern
Direct submission link
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
- To complete this lab, you need to do the following steps:
- Start a new project with your IDE using the starter files according.
- Debug the implementations for the following functions in
Color.cpp
andPicture.cpp
:Color::isBlack()
has one buggy line of codePicture::countBlackPixels()
has two buggy lines of codePicture::drawPixel()
has two buggy lines of codePicture::drawRectangle()
has one buggy line of code
- Test the functions using the test cases you are given in
test.cpp
. - 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:
- Read the RME to see what the function should do - what it Requires, Modifies, and the Effects.
- Set a breakpoint at the call to the buggy function in
test.cpp
. For example, start by placing a breakpoint in the functiontestColorisBlack
at the linecout << "Expected 0, actual " << blue.isBlack() << endl;
- Run the code and use “Step Into” to step through the buggy function in the Color or Picture class function.
- 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.
- Modify the statement(s) so the function will match the RME, and pass the test cases (match expected and actual output) in
test.cpp
. - Go back to steps 1-5 as needed until the actual output matches the expected output.
How to Submit
- When ready to submit to the autograder, visit https://autograder.io/web/project/2680. You will submit your
Picture.cpp
file only.
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.
- Once you receive a grade of 10 of 10 points from the autograder you will have received full credit for this lab.