Governor's Career & Technical Academy Arlington

CSC 222 Weekly Assignments: Week 10

CSC 222


Overview

This is the last week of the 1st quarter, so we need to bring closure to any outstanding evaluations such as the pointers and arrays projects.

Friday, November 3rd

Classwork

Questions asked by some of you on Wednesday combined with the pointers and arrays project submitted by Anfal and Anar gave me the idea for our next project, which we will begin today.

Project: Have a Little Class!

Motivation

The learning objectives of this project are:

  1. to gain practice separating C++ objects into their three parts: header file, source file, and testing program.
  2. to introduce you to the use of doctest for the last of these parts.

Process

  1. Meet your new partner. This is a paired project, and the psuedorandomly selected pairs for it are: Shangwen and Caleb, Jamethiel and Ivan, Marin and Ved, Fiker and Liam, Parker and Isaac, Akshay and Jackson, Luis and Anar, Cody and Johan, Dane and Anfal, James and Turner, and Trostin and Adonis.
  2. Come up with an idea for an object you could implement in C++. Think of the objects we've met thus far: Point, Time, Card, and Fraction, and use them for inspiration if nothing comes to you at first. Keep your object simple for this project.
  3. Assuming your object is MyObject, create three files: MyObject.h, MyObject.cpp, and test_myobject.cpp. The first of these will hold your object definition and member function prototypes, and the second the member function definitions.
  4. In the third file, start out with this:

    #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
    #include <doctest.h>
    #include "MyObject.h"
    using namespace std;
    
    TEST_CASE("Test can create and render MyObject") {
        MyObject myobj();
        CHECK(myobj.to_string() == "This is MyObject");
    }
    

    Fill in the header and source files so that this first test passes.

I leave it open ended where you take it from here. Keeping the learning goals in mind, add more tests and then more features to your object.

This project is due by the beginning of class on Monday, November 13th and will constitute your first grade for 2nd quarter.

Wednesday, November 1st

Classwork

We'll begin class today by looking at three submissions for the Fraction struct exercise, by Ivan, James, and Turner.

The rest of class time will be spent going through Chapter 14: Objects of vectors, and adding to our Card objects and learning several new features of C++.

Homework

Using your 90 minutes of allotted homework time, see how far you can get in Chapter 14: Exercise Set 1.

Be sure to commit all your work to your git repo. I'll be looking for a commit history that shows evidence of the process you use to develop solutions to these problems.

This assignment is due before the start of class on Friday.

Monday, October 30th

Classwork

I am getting more and more excited about doctest, which is just the kind of testing tool I was hoping to find for C++, having been spoiled by the original doctest developed by Tim Peters for Python.

Today in class I will show you how to configure your local C/C++ development environment for easy use of this wonderful resource.

Configuring CPATH for Local Libraries

CPATH is an environment variable that specifies the search path that the preprocessor uses for to look for somelibrary.h in a #include <somelibrary.h> directive.

To set our CPATH, we need to:

  1. create a directory where C/C++ libraries will be stored.
  2. set the CPATH environment variable to the path to that directory.

On my GNU/Linux box, I did this by:

  1. running:
    $ mkdir -p ~/.local/lib/gcc/include
    
  2. add adding the line:
    export CPATH=$HOME/.local/lib/gcc/include/
    
    to my .bashrc file (Note: You MacOS users will have to add this to .zshrc instead).

After copying doctest.h to ~/.local/lib/gcc/include, I can now just add:

#include <doctest.h>

to any program in which I want to use doctest.

Shout Outs

I keep telling you all how much I love this class. My rather ambitious plan to foster a community of learning environment is working out more spendidly than I could have hoped. We are learning from each other as we head into uncharted waters.

Today I'll share two projects, BlackJack, by Trostin and Marin, and ImageMagic, inspired by Luis Garces's flippixels example.

Homework

Complete the five exercises in Chapter 13 Exercise Set 1.