CO311: Modern Programming II

Calendar/Assignments

Week Date Lecture Topics & Suggested Homework
  Jan. 17 Martin Luther King, Jr. Holiday–No Class
1 Jan. 24 Welcome, Introduction (Syllabus, Website & Mailserver)

Review CO211 concepts and Exam: data types (fundamental C types, basic arrays, simple objects), control structures (if-else-if, switch, while, for), function prototyping & definition, parameterization, rules of scope, arrays, basic class definition

Complete by Jan. 31: Re-do the solution to Exercise 3.22 (page 144) as a separate function using a nested for loop. The separate function must have the following prototype:
void DrawCheckerboard(SimpleWindow &w);
2 Jan. 31 Begin step-by-step analysis of the answer for last week: emphasis on extracting code from one function to create a separate one.
Introduce Design concepts: how to go from problem to solution, programmer “rules of thumb”

First practical

Complete by Feb. 7: Re-read 4.9 (p191-198) on for loops.
On page 215, do Exercise 4.51 (Sample Answer) & 4.52 (Sample Answer). Your “code segments” should be complete functions (with an appropriate test program).
On page 216, do Exercise 4.65 (Sample Answer). The final program should have one function for input and one function that does “the work.”
3 Feb. 7 Finish step-by-step analysis of the answer from Week 1: emphasis on building and re-building for loops.

Practical #2 on breaking up a finished program into functions

Complete by Feb 14: Complete work on re-writing Exercise 3.22 (if you haven’t already). Re-write the finished DrawCheckerboard function (Sample Answer) to draw an 8×8 checkerboard on a 16cm×16cm window after receiving as input the size of the blocks. Ignore problems with block sizes larger than 2cm, or “whitespace” left over for block sizes less than 2cm. You should also have a test program that uses the function with the following prototype:
void DrawCheckerboard(SimpleWindow &w, float blockHeight, float blockWidth);
4 Feb. 14 More CO211 review: emphasis on arrays.

Practical #3 (after the lecture) on re-writing functions for different utility

Complete by Feb. 21: Write the code segments requested in exercises 10.20 (Sample Answer), 10.21 (Sample Answer) (page 550) with the following modifications:
  1. the “defines” should occur in main()
  2. the “work” happens in a function that you design and write, including a good prototype
  3. any “display” operations for the arrays should occur in separate function that you design and write, including a good prototype.

Make sure you know the answers (and why) for 10.21, parts e & f.

5 Feb. 21 New array topics: filling with random data for testing, saving the contents to disk
(multi-dimensional arrays if there’s time). Begin lecture on Sorting

Practical #4 (after the lecture) on simple array manipulation

Complete by Feb. 28: Write a program (Sample Answer) that randomly initializes an array of 20 integers, then receives user input from the keyboard. The program then searches the array to see if the user input matches an initialized value. If the value is matched, the program displays the location of the matching value in the array; if the value is not matched, the program indicates this as well. The program should be composed of several functions in addition to main():
void SetupArray(int array[], const int size);
int SearchArray(const int array[], const int size, const int key);
void DisplayResults(const int position);

The first function should put a random integer from 0 to 1000 in each of the 20 elements of the array. Use the C/C++ library functions srand() and rand() to generate the integers

The second function should search the array in sequential order and return the index/subscript/position (whatever you prefer to call it) of the first matching element in the array, as passed to the function in the argument key. If a match is not found, the function will return -1. 

The third function should display the location of the matching element (if found) and indicate that there are no matches if a match is not found.

6 Feb. 28 More array topics: Sorting Data and Selection Sort, Insertion Sort, “Shell” Sort demonstrations
C++ Programming Features: modular program compilation (creating and using your own headers and multiple project files)

Practical #5 (after lecture) on file I/O and arrays

Complete by Mar. 13: Practice breaking up your single-file programs into multiple files, similar to the way it was done in class. Any of the multiple-function programs you’ve written to date will lend itself to practicing this skill.

Read Section 8.1 and 8.2 (p364-373) to refresh your memory on creating classes

7 Mar. 6 Spring Break–No Class
8 Mar. 13 Reintroduce objects and begin OOP design: Read 8.1-4 (page 364), 8.6-7 (page384)

Practical #6 (after lecture) on file I/O and arrays
Practice Test (Sample Answer)for Practical #7 on data-only objects

9 Mar. 20 Using data-only objects to get real work done

Practical #7 (after lecture) on data-only objects
Practice Test for Practical #8 on doing real work with data-only objects

10 Mar. 27 Using dynamic criteria for tracking data, using data-only objects

Practical #8 (after lecture) on doing real work with data-only objects
Practice Test for Practical #9 on dynamic criteria data tracking

11 Apr. 3 Adding “intelligence” to objects: re-introduction of member functions to manage protected data

Practical #9 (after lecture) on dynamic criteria data tracking
Practice Test for Practical #10 on basic member functions

12 Apr. 10 Neat C++ toys: operator member functions

Practical #10 (after lecture) on basic member functions
Practice Test for Practical #11 on user-defined operator functions

13 Apr. 17 A truly useful class: the self-managing array

Practical #11 (after lecture) on user-defined operator functions
Practice Test for Practical #12 on self-managing arrays

14 Apr. 24 Easter Break–No Class
15 May 1 Leveraging objects previously created: Inheritance

Practical #12 (after lecture) on self-managing arrays
Practice Test for Practical #13 on simple inheritance

16 May 8 Brief introduction to the Standard Template Library

Practical #13 (after lecture) on simple inheritance


Comments? Email jim3@millard.org Last updated October 20, 2001