Pages

Wednesday, June 1, 2011

Session Outline: Wednesday, June 1, 12:10 PM to 1:00 PM SURGE 112 and 2:10 PM to 4:00 PM ENGR2 129

Brief

I will go over vectors today, then we will begin reviewing for the final.

Outline

  1. [0-10 min] Q & A on anything that's been covered
  2. [10 min] Quick review of the quiz.
  3. [10-20 min] Vectors
    1. Accessing Them
    2. Segmentation Faults
    3. Member Functions (size, empty, push_back, pop_back, and clear)
    4. Reverse a Vector
  4. [INFINITY min] Review of Quizzes

Lab Session

During the lab session today we will do a mini-premature review where we will go over the past quizzes and I will answer any questions people might have.

Wednesday, May 25, 2011

Session Outline: Wednesday, May 25, 12:10 PM to 1:00 PM SURGE 112 and 2:10 PM to 4:00 PM ENGR2 129

Monday's Session

Thanks for everyone who showed up! 

 

Brief

I'd like to focus mostly on vectors today, however, I will spend as much time on functions as needed.

Outline

  1. [0-10 min] Q & A on anything that's been covered
  2. [10 min] Quick review of the quiz. Concepts of the quiz will be covered when we cover functions though.
  3. [10-? min]  Functions
    1. Basics
    2. Void Functions
    3. Reference Parameters
  4. [10 min] Monday's Quiz Problems that we didn't get to Monday
  5. [10-? min] Vectors
    1. Const Reference
  6. [5 min] Daily Review

Lab Session

The lab session will be a slight bit different this week. We will do exercises from a worksheet I've written up. The early problems will address single concepts, then the last few questions will  combine all the concepts into one like you're used to during the regular labs.

Hope to see you guys there!

Monday, May 23, 2011

Session Outline: Monday, May 23, 5:10 PM to 6:00 PM SURGE 113

Brief

Functions are clearly still an issue so we will be working through a number of exercises on functions. We will also be going over vectors and hopefully get to casting.

Outline

  1. [0-10 min] Q & A
  2. [10-20 min] Today's Quiz
  3. [30 min] Function Exercises
  4. [10-15 min] Vectors
    1. Creation
    2. Adding to Vectors
    3. Constant References
  5. [10 min] What are those angle brackets < > for?
  6. [10 min] static_cast<type>(value)

Wednesday, May 18, 2011

Session Outline: Wednesday, May 18, 12:10 PM to 1:00 PM SURGE 112 and 2:10 PM to 4:00 PM ENGR2 129

Monday's Session

Thanks for everyone who showed up Monday. It seems that people are still having lots of trouble with functions so I'll make sure to keep touching on it until everyone is feeling totally comfortable.

 

Brief

The goal for this session is to reinforce the material on functions.

Outline

  1. [0-10 min] Q & A on anything that's been covered
  2. [10-30 min]  Functions
    1. Function Overloading
    2. Side Effects
    3. Void Functions
    4. Syntax etc.
    5. Forward Declarations and their Motivation
    6. More on Modularity (How and when to use functions, and when not to use them)
  3. [0-5 min]  Rand
    1. Low + rand() % (Max - Low + 1)
  4. [5 min] Modulus Operator

Lab Session

I've copied the lab questions below. Hope to see you guys there!Remember: I can't help you with homework! Do the first lab option if your having issues with your homework!

Lab Option 1 (designed to help with your homework):

Create a console program which displays a grid of N by N x-s (where N is some constant value). One of the x-s should be marked as an o. The user should be prompted to enter n, e, s, or w (north, east, etc.) and when they do, the grid should be reprinted with the o moved accordingly. This should repeat infinitely. For example, in a 4x4 grid:
x x x x
x x x x
x x o x
x x x x
Enter a direction: n

x x x x
x x o x
x x x x
x x x x
Enter a direction: e


x x x x
x x x o
x x x x
x x x x
Enter a direction:

For this option you'll need to use a nested loop. You'll also need to store the x and y coordinate of the o in integer variables.

Lab Option 2 (designed to help you with the new material this week and next week's lab):
We will be recreating a program from a previous lab question, via a different method. Create a program which displays a series of rectangles like below
Where the number of rectangles is defined by a constant. To do this without doing some insane math, you'll have to make a helper function which allows you to specify the center of a rectangle to create a rectangle rather than the lower left corner.


Lab Option 3 (designed to challenge those who are finding things easy or want to challenge themselves, for added incentive I'll buy you a danish from bytes if you successfully complete this option):
Make an  instinct program which displays a circle onto the screen and allows you the user to use the arrow keys to move the circle around. To do this, take a look at the Real Time functions in the instinct reference. Once you have that working, try to make a slower moving square that chases the circle around.

Monday, May 16, 2011

Session Outline: Monday, May 16, 5:10 PM to 6:00 PM SURGE 113

Brief

The goal of this lesson is to get everyone better familiar with creating functions and how to use incremental development (aka Divide and Conquer) using test harnesses.

Outline

  1. [0-10 min] Q & A 
  2. [5-10 min] Go over today's quiz
  3. [10 min] Mini-Quiz
    1. [Break up the following code into separate functions]
      int main()
      {
          int input1 = prompt("Enter a number: "),
              input2 = prompt("Enter another number: ");  


          // Limit input1 between 5 and 9
          if (input1 < 5)
              input1 = 5;
          else if (input1 > 9)
              input1 = 9;

          // Limit input2 between 3 and 7
          if (input2 < 3)
              input2 = 3;
          else if (input2 > 7)
              input2 = 7;


          return 0;
      }
  4. [10-15 min] Review of Functions
    1. Syntax
    2. Forward Declarations 
    3. Overloading
    4. Reference Parameters
    5. Compositions
  5. [5-10 min] Constants
    1. Global Constant Variables vs. Global Variables
  6. [10-20 min] Incremental Development (Divide and Conquer)
    1. Test Harnesses
  7. [5-10 min] Review of Scoping 
    1. int foo()
      {
          int x = 3;
          return x;
      }

      int bar()
      {
          int y = 5;
          return y;
      }

      int main()

      {
          int x = bar();

          int q = foo();

          cout << x << q;


          return 0;
      }
  8. [5-10 min] Review of Dot Operator
    1. Member Functions 

Wednesday, May 11, 2011

Session Outline: Wednesday, May 11, 12:10 PM to 1:00 PM SURGE 112 and 2:10 PM to 4:00 PM ENGR2 129

Monday's Session

Thanks for everyone who showed up. We'll be touching on functions more today if you have more questions on them.

 

Brief

The goal for this session is to get everyone to accept functions as their best friends.

Outline

  1. [0-10 min] Q & A on anything that's been covered
  2. [2 min] Quick Syntax Review
    1. Return Value
    2. Name of Function
    3. Parameters
  3. [10 min] Mini-Quiz
    1. Write a function that, given two floating point numbers, returns the distance between those two numbers on the number line.
      Hint: In math this would be something like |a-b| (super simple).
  4. [10-30 min]  Functions
    1. Function Overloading
    2. Side Effects
    3. Void Functions
    4. Syntax etc.
    5. Forward Declarations and their Motivation
    6. More on Modularity (How and when to use functions, and when not to use them)
  5. [5 min] Using Rand
    1. Low + rand() % (Max - Low + 1)
  6. [10 min] Functions and Instinct
    1. Instinct Objects are Just Objects
    2. Exercise: Create a function that, given three points, draws a triangle to the screen.

Lab Session

I've copied the lab questions below. Hope to see you guys there!Remember: I can't help you with homework! Do the first lab option if your having issues with your homework!

Lab Option 1 (designed to help with your homework):
Create a program which displays four rectangles (buttons) onto the screen. When the user clicks on a button it should turn red. When the user clicks the button again it should turn back to black. If you user makes the right combinations of red and black buttons, a secret message should be displayed. Your program should implement a couple of functions besides the main.
An inside function like the one Kris showed in class. Given a rectangle and a point it should return true or false depending on whether or not the point is inside of the rectangle.
A checkWin function that returns true if the correct combination of true and false boolean values is given. So the signature will look something like: bool checkWin(bool a, bool b, bool c, bool d).

Lab Option 2 (designed to help you with the new material this week and next week's lab):
Create a function distance which will give the distance between two Points, two Integers, two Floating-Point Numbers, and two Circles depending on the type of the argument given.

Lab Option 3 (designed to challenge those who are finding things easy or want to challenge themselves, for added incentive I'll buy you a danish from bytes if you successfully complete this option):
Write a function which takes in a string in the format "Lucy {verb} over the {noun} and {verb} through the {noun}." and then prompts the user for a verb, a noun, another verb, then another noun. Then returns a string containing the ad-libbed phrase. This is perfectly possible with the tools you have and shouldn't even be very much code at all. You'll need to use find and substr extensively.

Monday, May 9, 2011

Session Outline: Monday, May 9, 5:10 PM to 6:00 PM SURGE 113

Brief

The goal of this lesson is to make sure everyone absorbed all the material from last week (and make sure no one is behind in the content) and get everyone prepared for the new material this week.

Outline

  1. [0-10 min] Q & A 
  2. [10 min] Mini-Quiz
    1. [Break up the following code into separate functions]
      int main()
      {
          int input;
          cout << "Enter a number: ";
          cin >> input;

          int input2;
          cout << "Enter another number : ";
          cin >> input2;

          for (int i = input; i < input2; ++i)
              cout << i;

          for (int i = input2; i < input; ++i)
              cout << i;

          return 0;
      }
  3. [10-15 min] Review of Functions
    1. Modularity (how to use functions)
    2. Syntax
    3. Forward Declarations
  4. [0-5 min] Review of If Statements 
    1. Blocks 
    2. Comparison Operators 
    3. Boolean Logic Operators 
    4. Conditional Expressions Outside of the If Statement
  5. [5-10 min] Review of For and While Loops 
    1. Output a countdown from a given n 
    2. The do ... while loop 
    3. Control Flow 
    4. Loop Invariant (There should be a condition that is true at the start of the loop and after each iteration of the loop) 
  6. [5-15 min] Review of Scoping 
  7. [5-15 min] Go over essentials 
    1. Declaring/initializing/assigning/modifying/etc. variables 
    2. Stream insertion and extraction (cin and cout) 
    3. Arithmetic with various data types 
    4. Strings, concatenation, etc. 
  8. [5-10 min] Review of Dot Operator