Pages

Wednesday, April 20, 2011

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

Monday's Tuesday's Session

Sorry again for the time mix-up! I'll be recovering much of what I went over yesterday today. I'll also be asking about how everyone feels about the 5-6 time on Mondays, as it seems that everyone wants an earlier session.

Brief

The goal for this session is to get everyone all set for the homework this weekend and to get everyone intimately familiar with the concept of control flow.

Outline

  1. [0-10 min] Q & A on anything that's been covered
  2. [10 min] Control Flow
    1. Verbal Quiz
    2. Turing
  3. [10-15 min] Dot Operator
    1. Classes as collections of objects and functions (members)
  4. [10-15 min] If Statements
    1. Comparison Operators
    2. Blocks
      1. Styling
  5. [10-15 min] While Loop
  6. [2-10 min] Instinct
    1. Basic Math
    2. Address Any Questions
  7.  [5-10 min] Boolean Logic Operators
  8. [5 min] Time Check

Lab Session

The lab this week will be a little different than usual. There will be three different questions you can choose from (feel free to do more than one though!). Each one focuses on different concepts (except the third which brings everything together and offers a bit of an extra challenge). Every question is perfectly doable with the knowledge that you have (I'm 100% sure) and shouldn't take you too long (though if it does then that's good because now is the time to learn the material).
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 an Instinct program which asks the user to click on a point in the window. Your program will then draw a house (made up of a rectangle with a triangle on top) with the base's (the rectangle's) bottom left corner at the bottom left of the screen and the base's top right corner where the user clicked. The roof (the triangle) should be placed exactly centered on top, exactly as wide as the house, and HALF as tall as the base. The roof should be GREEN and the base should be BLUE.

Lab Option 2 (designed to help you with the new material this week and next week's lab):
There's actually two separate sub-options in this option. One is implementing what Kris did in class with a little extra (don't cheat and look at his code!) but if you think that's too easy (you should try it first though) then there's a much trickier one if you'd like the challenge.
2.1: Create a program which first asks the user for how many tries they would like to allow themselves (the input should be between 0 and 100 inclusive and should continue prompting the user until they get it in the permissible range). The program should then ask the user to enter a number between 0 and 1000 (if the user guesses outside of the allowable range the program should scold the user then exit). It should then compare their answer to some secret number (choose some random one in that range) and tell the user whether the number is smaller, greater, or the correct number. It should then let the user try as many times as they specified in the beginning.
Note for this one: the exit(0) function allows you to stop your program whenever you want.
2.2: Create a program which asks the user to think of a number between 0 and 100,000, and then for how many tries they would like to give the computer. The program should then guess 50000, and ask the user if that number is higher, lower, or equal to the user's guess (the user should enter h, l, or e respectively). If the user's guess is too high, the next guess should be 25000, if the guess is lower, next guess should be 750000, if the guess was right, some message should appear ("Yay I got it!" or something akin). This process should continue until the computer guesses the right number or the amount of tries was depleted (in which case the computer should say something like "Aww, darnit, maybe I'll get it next time."). This problem is deceptively difficult, so be careful!

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):
Create an Instinct program which displays three blue rectangles on the screen. The first rectangle should take up the first (leftmost) third of the screen. The second rectangle should take up the second (middle) third of the screen. The third rectangle should take up the third (rightmost) third of the screen. The user should then be prompted to click on one of the rectangles. The program should then check to see if the user clicked on the correct rectangle (pick one at random to be the "correct" one). If the user clicks on the right one, the rectangle should turn green and the program should exit. If the user clicks on the wrong one, the rectangle should turn red and the user should be allowed to try once more. If the user again fails to click on the right one, the correct rectangle should turn green, and both of the other rectangle should be red. The program should then exit.
Note: You may find it easier to make a program that deals with n number of rectangles...

No comments:

Post a Comment