< Back

Lecture 8 - Test Review


As usual, create a directory to hold today's activities:

$ mkdir ~/cs170/labs/lab8 
$ cd ~/cs170/labs/lab8 

Lab Activity 1
bins.py Quadratic.h Quadratic.cc
Test Review

In addition to the written portion of the test, there will be a coding portion. This will be done on the computers. For practice, attempt the following exercises, alone:

  1. Python Practice

    Create a class called Bin, which stores a list of all of the elements currently inside of the bin. Include a method store_item(item) that allows you to add objects to the bin. Create another class called RecycleBin, which inherits the Bin class. Your RecycleBin class should have at least a method called empty(), which removes everything from the bin.

  2. C++ Practice

    Create a class called Quadratic, which is a class that represents a degree 2 polynomial as a collection of coefficients. Your class should have a method called evaluate, which takes a single floating point values as a parameter, and computes the result of evaluating the quadratic polynomial with the passed parameter being used as x. It should return this result.

    You should also have a method that outputs the string that represents the equation.