Phase 5
Overview
In this development phase, you will implement the following member function(s) of the IntList
class:
push_back(…)
insert_after(…)
These operations are described in the
Keep that page open so you can refer to it!
Steps
As always, don't forget to check out the Helpful Hints.
1. Plan
- Plan how the
push_back(…)
function should work. - Plan how the
insert_after(…)
function should work. - Add an image,
Phase_5.jpg
, to theintlist/Planning
folder in your assignment repository. - Make sure the file was added successfully by viewing it on the GitHub website.
2. Write Tests
- Write tests for
push_back
- Write tests for and
insert_after(…)
3. Implement
- Use your plan to write your implementation of
push_back
inintlist.cpp
. - Use your plan to write your implementation of
insert_after(…)
inintlist.cpp
.
4. Test & Fix
- See if you can find any bugs in your implementations, and if you do, sort them out.
- Think about how someone else might have accidentally fundamentally misunderstood what equality on lists means and make sure your test would catch those kinds of mistakes.
Helpful Hints
You Can Develop push_back(…)
First
If you like, you can plan, implement, and test push_back(…)
before moving on to insert_after(…)
.
Remember, insert_after(list.end(), …)
is Forbidden
While does make sense to add an element after the last element (that's identical to push_back(…)
, it doesn't make any sense to insert after the past the end point—you can't have something “beyond past the end”.
I think I could detect this misuse and fail an
assert
ininsert_after
. Should I…?Totally, if you want to. You just can't test misuse in your tests.
(When logged in, completion status appears here.)