Grace Hopper Center

CSC 222 Weekly Assignments: Week 17

CSC 222


Overview

This week we will complete Chapter 14: Classes and invariants and Chapter 15: Extending classes, bringing to a close our study of object-oriented programming with C++. That will then leave us three weeks for final projects applying all we have learned.

CPE study sessions will be available this Saturday, January 10 and next from 9 am to 12 noon. This will be your last opportunity to prepare for and retake the certification exams during our course. Please let me know if you plan to attend.

Thursday, December 19th

Classwork

We'll begin class today by following up on two conversations from last class. The first was a conversation I had with Delanie and Robbie. Take a look at the following and replace the comment line with a line that will make the program work as intended (I predict Delanie and Robbie have the highest chance of getting this right):

#include 
#include 
using namespace std;

string remove_char(string s, char c) {
    if (s.empty()) {
        return "";
    }
    if (s[0] == c) {
        return remove_char(s.substr(1), c);
    }
    /* Replace this line with a line that will make this work. */
}

int main() {
    cout << remove_char("Mississippi", 'i') << endl;
    return 0;
}

When you replace the line, compile and run it, it should print: Msssspp.

The next thing I'll show you comes with a conversation I had with Sean. He choose to work on exercise 5 from Chapter 14 Exercise Set 0: Chapter Review, which asks you to apply new skills to an old object: points.

Homework / Evaluation

Tuesday, December 17th

Classwork

We'll begin class with a quick review of where we left off before winter break.

After that we will discuss Chapter 14: Classes and invariants and begin working the exercises together.

Homework / Evaluation

Read Chapter 15: Extending classes, taking notes in a markdown file in your git repo.