CSCI 261 Programming Concepts (C++)

Fall/Winter 2011

Lecture Topics & Homework

Week 1: The Start of a Journey

Welcome to 261! The goal of this week is to dive in and compile your first program. The important concepts this week are to know how to compile and run a program with Visual Studio and how to define constants. We're also covering chapter 1 of our textbook.

Aug 24

Lecture 1: Introduction, Constants

Understand that constants are used to declare "facts that don't change." Know how to recognize a C++ constant.

Homework due Aug 26:

  • Review the syllabus and all other pages on this site.
  • Make sure you can access this class on blackboard.
  • Enroll in this class on piazza (you should have received an email invitation).
  • Start reading Etter chapter 1

Aug 26

Lab 1: Hello World!

Learn how to compile and run a C++ program using Visual Studio. Recognize and modify constants. Learn how to properly submit all programming assignments.

Homework due Aug 29:

  • 01_helloWorld
  • Finish reading Etter chapter 1 (merely skim section 1.4)

Week 2: Programming Fundamentals (Variables, Operators, Expressions)

Last week you learned that we can "teach the computer about facts in the world that don't change"; the keyword const; and how to compile and run a program in VS. The goal of this week is to introduce you to some basic syntax rules about C++, how to declare facts about the world that do change, and how to combine those facts with operators to create expressions. Your goal is at the end of this week is to enhance an existing graphical program such that it can successfully interpolate a value between two points of data. The important concepts this week are to know how to declare and use variables and expressions. We're also covering chapter 2 of our textbook.

Aug 29

Lecture 2: Compilation Process, Program Anatomy, Intro to Variables, Expressions & I/O

Understand how "code" becomes programs through compilation, linking and execution (what happens when you hit ctrl-F5). Grasp the general anatomy of simple C++ programs. Learn how variables are used to declare "facts that may change" and learn what cin and cout do.

Homework due Aug 31:

Aug 31

Lecture 3: C++ Fundamentals

Today you will learn about some basic C++ syntax rules. Understand how to declare variables using proper syntax. Learn about primitive operators such as addition and multiplication. Learn how to combine operators and variables to form expressions.

Homework due Sep 2:

Sep 2

Lab 2: Linear Interpolation

Exercise what you've learned this week by improving a graphical program that calculates an interpolated value between two points of data. This is a useful skill for many engineering contexts.

Homework due Sep 5:

Week 3: Making Decisions (Boolean logic and Selection Statements)

Now that you've learned how to teach the computer about simple facts in the world and exercised some basic C++ syntax, it's time to do something more useful: teaching the computer how to make decisions, given what it understands about the world. Your goal at the end of this week is to implement a game of Rock, Scissors, Paper. The important concepts this week are to understand that boolean expressions get evaluated and yield a value and how to use selection statements to model logical decision-making. We're also covering 3.1 and 3.2 of our book.

Note: be sure to download this week's assignment pack.

Sep 5

Lecture 4: Boolean Logic

First, review operations with mixed types: it seems trivial but it's something that all programmers tend to overlook. Next, learn about the life and death of George Boole, it's a sad story (yet somehow we'll laugh, in honor of his great work of course). Learn about boolean logic and how any decision can, in theory, be reduced to a Boolean expression. Learn aobut truth tables, logical expressions and how true and false are representations of 0 and 1.

Homework due Sep 7:

Sep 7

Lecture 5: Selection Statements

Today you will learn about how to teach the machine to make decisions based on Boolean logic. Understand how to use selection statements with if, else if and else. Learn how to model more complex decisions with nested selection statements, and exercise your understanding of how computers represent character data.

Homework due Sep 9:

Sep 9

Lab 3: Rock, Paper, Scissors: Fight!

Exercise what you've learned this week by creating a simple console-based game of Rock, Paper Scissors. This assignment tests your ability to implement more complicated logic, your understanding of how computers handle character data, and how to use pseudocode to help guide your program development.

Homework due Sep 12:

Week 4: Doing Things Repeatedly (loops with while and for)

Recall what we said about computers being very good at doing repetitive tasks. This week you will learn how to tell the computer to do things repeatedly, and how to modify what the computer does during each repetition. The important concepts this week are to understand common loop "patterns," and how to use C++ loop syntax to model repetitive tasks. We're also covering sections 3.4 and 3.5 of our book.

Don't forget to download this week's assignment pack.

Sep 12

Lecture 6: Loops with while

Today you will learn about how to teach the machine to complete repetitive tasks, which computers are incredibly good at doing. Today you will learn to think about "stopping conditions" and how to modify each task repetition. Understand how to implement loops with while and recognize common looping patterns.

Homework due Sep 14:

Sep 14

Lecture 7: Loops with for and Intro to Machine Randomness

Another useful tool for implementing repetitive tasks is the for loop. Learn about the similarities between while and for loops and how to convert a while loop to a for loop (and vice-versa). Excercise your understanding of loops with a more challenging version of the previous assignment. Learn about pseudo-random numbers and how to use rand().

Homework due Sep 16:

Sep 16

Lab 4: Number Guessing

Exercise what you've learned over the past two weeks by creating every aspiring game programmer's first game: guess-the-number. Don't be fooled, it's not as simple as you might think. Exercise using rand() and both loops and selection statements together.

Homework due Sep 19:

Week 5: Data, Input/Output

You've learned how a program can be "interactive" by accepting keyboard input and printing information to the screen. This week you will take a first step toward automation and persistence, creating programs that can read lots of data from files and write data to files. Think of how the data "outlives" the execution of the program. The important concepts this week are how to read and write data. We're also covering sections 4.2 and 4.5 of our book.

Don't forget to download this week's assignment pack.

Sep 19

Lecture 8: Reading Data

You've learned how to provide the machine information interactively via the keyboard. But what if you need to provide a machine lots of information? How does a program like iTunes read an .mp3 file and generate music? Today you will learn how to create programs that can read data from text files and act upon that data.

Homework due Sep 21:

Sep 21

Lecture 9: File I/O in Detail, Writing Data

Have you ever thought about how the information your programs print to the screen just "disappear" once the program ends? What if you wanted to "keep" the output from your program around for later use? We call this "data persistence," in its most simple form. Now that you've learned how to read data, today you will create a program that writes information to a text file.

Homework due Sep 23:

Sep 23

Lab 5: Simple Stats

Now that you've learned how to read and write data, consider how much of the data we see is presented in a tabular format of rows and columns. Rather than process each piece of data individually, you often need to extract multiple pieces of data in one "row." Learn how to chain the >> operator with your loops to act upon rows of data.

Homework due Sep 26:

Week 6: Abstraction, Encapsulation and Functions

You have now learned about the fundamental concepts needed to write useful programs. This week you will begin to learn about a key abstraction in programming: the function. Think of how meaningful function names help your programs read more like human language, and how functions are like "mini programs" that abstract the work that they do, letting you focus on how to use them, not how they do their work. The important concepts this week are how to use and define functions; and what "scope" is all about. We're also covering part of chapter 5 of our book.

Sep 26

Lecture 10: Functions

You've learned the nuts and bolts of programming, now learn about how to combine those nuts and bolts into more effective, readable, maintainable programs. Today you will learn about what functions are, how to use them and how to define them.

Homework due Sep 28:

Sep 28

Lecture 11: More FUNctions

Getting our heads around functions takes time and practice. Today we will practice defining and calling functions, discuss more about parameters and arguments, how arguments are passed by value, and what this thing called "scope" is all about. You will also learn about how to use function prototypes above main and definitions below.

Homework due Sep 30:

  • 15_robot
  • Continue reading Etter 5.1 - 5.3 (p198)

Sep 30

Lab 6: Mines Dating Diary

Exercise your ability to design functions that are reusable. In this lab you will create a program that records your very busy dating history here at Mines. You will use functions to abstract away low-level "busy work," resulting in a main() program that is easy to read (even for your programming date).

Homework due Oct 3:

Week 7: Functions, Libraries and a Taste of Recursion

You have now begun to learn about how functions allow you to write a bit of code once and re-use it. You have also seen how functions result in more readable programs, and how using libraries built by others allows you to write productive programs. This week we will be continuing our practice with defining and using functions, and we will end with a brain-bender: functions that call themselves. The important concepts this week are scope, more function definitions and use, and recursion. We will also begin preparing for the midterm exam.

Oct 3

Lecture 12: Functions and Scope

It takes time to get comfortable with parameters vs. arguments and to gain an understanding of function "scope." Today you will learn about "global" scope vs. "local" scope and a common use of global variables: to declare constants that multiple functions may need to use. In addition, we will be practicing more with functions and begin to test your knowledge with questions similar to what you can expect on the midterm exam.

Homework due Oct 5:

Oct 5

Lecture 13: Recursion

You should now be comfortable with declaring functions and calling functions; with the difference between parameters and arguments; global and local scope; and how functions encapsulate "units of work" that you can use over and over again. Today we are demonstrating an important concept in computer science that is certain to melt your brain: functions that call themselves, also known as "recursion."

Homework due Oct 7:

Oct 7

Lab 7: General Help & Review

There is no new assignment for today's lab. Today is a general help session. We strongly recommend you use this time to get answers to your questions about assignments and C++ syntax/behavior.

No homework! Study for the exam.

Week 8: Concept Review and Midterm Exam

If you've gotten this far and your brain hasn't melted too much, then congratulations. Learning how to program is not easy. This week, we will review all of our concepts, practice what we've learned and prepare to ace the midterm exam. There are no new homework assignments nor a lab this week.

Oct 10

Lecture 14: Intro to Analyzing Algorithms and Midterm Review

What determines if a program is "good" or not? In computer science, one aspect of measuring a program's "goodness" is to estimate how well it works when provided some incredibly large input. Today you will be introduced to "Big O" notation and we will analyze your factorial function. We will also begin reviewing for the midterm exam.

No homework! Study for the exam.

Oct 12

Lecture 15: Review

Today we will be reviewing our concepts and giving you a taste of what to expect on the first midterm exam.

No homework! Study for the exam.

Oct 13

Exam I

The exam is at 8:30PM. We know, exams at night aren't ideal... think of it as a party. See the exam page for locations.

No lab this Friday.

No lab on Oct 14.

Week 9: Collections of Things (Intro to Data Structures and One-Dimensional Arrays)

So far in your programs, you've been dealing with individual pieces of data. This week, learn how to create collections of data using a simple data structure: the array. The important concepts this week are how to declare arrays, how to put things in arrays, and how to access things that are in the array. We're also reading parts of chapter 6 from our book.

Oct 19

Lecture 16: Exam Review, Introduction to Arrays

A critical element in computer science is the "data structure": something that can store multiple pieces of data together. For example, we might want to create a "list" of football scores, or temperature readings. Today you will be introduced to a fundamental data structure called an array. We will learn about how arrays work, how to create one, store things in it, and access the things stored inside of it. We will also review the midterm exam.

Homework due Oct 21:

Oct 21

Lab 8: Meet Array

Today we are finishing up our introduction to arrays and using arrays with for loops. Exercise your ability to define functions and your ability to create, use and iterate over array structures.

Homework due Oct 24:

  • Finish reading Etter 6.1

Week 10: Simple Data Structures & Program Design

What makes arrays special? What are their benefits and drawbacks? This week, learn how arrays really work and what makes them an efficient data structure. Learn about multidimensional arrays and how to work with two-dimensional arrays. At the end of the week, you will use everything you have learned thus far to create a meaningful program. The important concepts this week are multi-dimensional arrays. We're also reading parts of chapter 7 from our book.

Oct 24

Lecture 17: Variables, Arrays, Memory, Searching & Sorting

Have you ever thought about where variable values "go" when you assign them? No? Today we will show you how memory works, especially when it comes to arrays. We will learn about some benefits and drawbacks of arrays, and what it means to be able to access array elements in "constant time." In addition, learn why sorting and searching are classic, important topics in computer science.

Homework due Oct 26:

Oct 26

Lecture 18: Multi-dimensional Arrays

You should now be fairly comfortable with arrays that store primitive data, such as numbers. What happens when arrays "contain" arrays? Today you will learn about two-dimensional arrays and some common uses and patterns. Exercise your ability to work with two-dimensional arrays by creating a colorful grid of squares.

Homework due Oct 28:

21_colorGrid has been deprecated due to lab issues. Read this to learn more.

Oct 28

Lab 9: Letter Frequency

Today's lab is designed to test you on your ability to design a complete program that exercises everything you have learned in the semester. Create a program that reads in some data and displays some frequency statistics by drawing a bar graph.

Homework due Oct 31:

Optional: You may complete 22_letterFrequency if you wish. It's way cooler, but will not run on our lab machines at this time.

Week 11: Objects

While numbers and letters are represented as primitive values, this week you will learn how to use more "complex" and meaningful abstractions: objects. Objects can be used in programs to abstract and represent real-world things. This week you will learn about how to use objects through the API they provide.

Oct 31

Lecture 19: Objects and Strings

Today you will learn more about what it means to be "an object" to the machine. Get comfortable using objects first, and next week you will learn how to define your own (more exciting) objects to the machine. Today we will explore string objects and how you can use them more effectively in your programs.

Homework due Nov 2:

Nov 2

Lecture 20: Vector Objects

While arrays have their place, in most contexts you will want a data structure that is somewhat more flexible. Today you will learn about vectors and how you can use them instead of arrays.

Homework due Nov 4:

Nov 4

Lab 10: Object Instantiation & Simple Simulations

Today's lab teaches you about different ways to instantiate (create) objects, and challenges you to experiment with an unfamiliar API. Create a program that simulates the process of reading a book.

Homework due Nov 7:

Week 12: Defining Your Own "Things" to the Machine (Intro to Classes)

You've now been introduced to four different objects: strings, vectors, Persons and Books. You learned how to create instances of objects and how to use the "dot operator" to access an objects properties. This week, learn how to describe your own "things" to the machine by declaring classes.

Nov 7

Lecture 21: Introduction to Classes

Now that you know how to instantiate and use objects, learn how you can define your own types of things through a mechanism we call "class definition." Today you will learn what a class is, the difference between objects and classes, and how to define classes that represent real-world things to the machine. We will also be covering chapter 8 of our book.

Homework due Nov 9:

  • Read Etter 8.1, 8.2 and 8.4 (skip 8.3)
  • 26_boxTest

Nov 9

Lecture 22: More about Classes

Now that you can define a basic class with properties and constructors, today you will learn how to define "constants" across an entire class of things, define member functions, the difference between public and private access, and the getter/setter pattern. You will enhance your initial Box class to ensure it cannot have negative attributes, and you will enable Boxes to "tell you" their volume.

Homework due Nov 11:

Nov 11

Lab 11: Moving Squares

Leverage what you have learned about classes this week to create a program in which you define what it means to be a "square" that can move, and create an animation that demonstrates the properties of a collection of Squares.

Homework due Nov 14:

Week 13: Classes, Simulation, Passing By Reference, Objects and Memory

Congratulations! We have now covered all of the fundamental programming concepts needed to create useful, meaningful, object-oriented programs. This week you will be responsible for implementing simple simulations using your own functions and classes. We will now be learning about references and how objects are stored in memory, and why you should usually pass objects by reference. We'll also be covering section 5.3 of our book.

Nov 14

Lecture 23: Pass-by-Reference, Objects & Memory

To date, we have explained that function scope is independent: "what happens in braces stays in braces." However, there are cases where we want a function to be able to modify the actual piece of data it is passed. This is often the case when using functions that receive objects as arguments. Today, learn a little more about memory and how to declare functions that receive their arguments by reference. We will implement a simple troll batttle and also cover section 5.3 of our book.

Homework due Nov 16:

Nov 16

Lecture 24: Callees, Helper Methods, Method Chaining, Random Walk

Today you will learn more about how to think about member functions, how to reduce code duplication with private helper functions, and how to use method chaining to call functions on objects that other functions return. In addition, we will present the Random Walk (aka Drunkard's Walk) phenomena and see if you can create a simulation to help deduce an answer.

Homework due Nov 21:

Nov 18

Lab 12: General Help & Review

There is no new assignment for today's lab. Today is a general help session. We strongly recommend you use this time to get answers to your questions about assignments and C++ syntax/behavior.

No new homework, yay!

  • Finish previous homework
  • Prepare for exam 2

Week 14: Concept Review and Exam II

Take a look: you've now written 30 programs and have learned about programming concepts that almost all modern programming languages provide. And your brain is still intact! This week, we will review all of our concepts, practice what we've learned and prepare to ace the midterm exam.

Nov 21

Lecture 25: Review

Today we will be reviewing our concepts and giving you a taste of what to expect on the second midterm exam.

No homework. Study for the exam.

Nov 22

Exam II

The exam is at 6:30PM and should take approximately one hour to complete. See the exam page for locations.

See you after the holiday break.

Week 15: Peeking Under the Hood (Events, Memory)

This week we will review the midterm exam, discuss the final project, equip you with some knowledge of event-handling and discuss your programs' use of memory.

Nov 28

Lecture 26: Exam Review, Final Project Discussion

Today we will be reviewing solutions from the midterm exam and we will discuss the final project.

Homework due Nov 30:

  • Choose your final project partner
  • Email your instructor your partner's name

Nov 30

Lecture 27: Events, Interrupts; Memory, Stack, Heap, Stack Frames

Today we will learn about hardware interrupts and event handling. In addition, we will be taking a deeper look at how your program uses memory, and what the "stack" and "heap" are.

Project Milestone for Dec 2:

  • Make sure the provided project runs out of the box in your environment
  • Complete the README.txt

Dec 2

Lab 13: Game of Life

During today's lab, learn how to properly add new files to your Visual Studio project and learn about how to capture mouse clicks and key presses using OpenFrameworks.

Project Milestone for Dec 5:

  • Draw a 100x100 grid
  • Capture mouse clicks that result in cells being drawn
  • Clear the grid when R is pressed

Week 16: Pointers & Review

Hooray! Your last week of class. This week we will discuss pointers and we will review what we've learned this semester.

Dec 5

Lecture 28: Pointers

Today we will discover what pointers are and how they work. While there is no new homework assignment, it is important to read and execute the sample code provided below.

Homework:

  • Read and execute the pointers sample code.
  • Read Etter chapter 9, pages 397 - 406
  • Optional reading: pages 407 - 429
  • Complete the final project.

Dec 7

Lecture 29: Semester Review

Holy cow! Your final class for the semester. Today we will be reviewing what we have learned and give you some tips for preparing for the final exam.

Homework:

  • Begin studying for the final exam.
  • Complete the final project.