CS 70

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

  • LHS Cow speaking

    Keep that page open so you can refer to it!

Steps

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 the intlist/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 in intlist.cpp.
  • Use your plan to write your implementation of insert_after(…) in intlist.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”.

  • Sheep speaking

    I think I could detect this misuse and fail an assert in insert_after. Should I…?

  • LHS Cow speaking

    Totally, if you want to. You just can't test misuse in your tests.

To Complete This Part of the Assignment…

You'll know you're done with this part of the assignment when you've done all of the following:

(When logged in, completion status appears here.)