Intro CS Assignments
Assignments by week:
Fall Term:
Winter Term:
Spring Term:
Monday, October 22
Description
Wrapping Up Recursion
Homework
  • Tomorrow we'll begin working on the WhatADrag lab:

    Your browser does not support the canvas tag.

    You should start the lab by making a program with the boxes in their initial positions, and with the correct border, color, and transparency. By the start of next class, have a program with the boxes in their initial positions (you don't need to email it to me, just have it ready for me to see). Then, start thinking about how you're going to get the boxes to follow the mouse like they do in the demo. Note that the demo has the following features:

    • The boxes move independently of each other
    • The boxes move ONLY when you click inside them (not if you drag through them!)
    • The boxes continue to move while dragging, even if the mouse gets "ahead" of the boxes
    • The boxes move relative to the mouse, not necessarily from its exact center or corner

    We'll go over techniques for dragging during class tomorrow.

Tuesday, October 23
Description
Drag and Drop
Homework
  • Complete the WhatADrag lab. Final version of this lab is due at the end of next class. You'll have some time in class to ask final questions and work on it, but you should aim to have as much done as possible before class as you may not have enough time to do it all just during class time. Some hints:

    • Write two functions that each return a boolean and take no parameters. The should return "true" if the current mouse position is inside one of the boxes, and "false" otherwise. You need two functions because there are two boxes (one function goes with each box).
    • Write two functions that return nothing and take two float parameters (each). The functions should move one of the boxes by the specified amounts (one parameter is for the x direction, the other is for the y direction).
    • Create a mouseDragged() function. Inside it, calculate how far the mouse has moved since the last run of the draw() function, and feed those numbers to the functions that move your boxes. This should allow you to move the boxes around when you drag the mouse.
Thursday, October 25
Description
WhatADrag Lab
Homework
  • Read the arrays handout that I sent to you via e-mail.
  • You may also read about arrays on the Processing website.
  • Write a short program that assigns the following numbers to an array of integers: 1 2 4 8 16 32 64 128 256 512 1024. You may assign them using any of the three techniques in the reading. Your program should also print out each of the values in the array, one per line, using a println() statement. Submit your program to me by the beginning of next class.
Friday, October 26
Description
Introduction to Arrays
Homework
  • Consider the following problems, which we will do together during the next class. You don't have to turn these in via email, but be ready for me to call on you in class to answer!
    • Write a function that creates an array of 100 integers, and fills the array with the first 100 square numbers (1, 4, 9, 16, ..., 10000).
    • Write a function that, given an existing array of floats, replaces each value in the array with the square root of the original value. For example, if the array contained "1, 2, 3, 4", it would end up with "1, 1.41421..., 1.732..., 2.0" inside it.
    • Write a program that draws an ellipse on the screen every time the mouse is pressed. The fill color of the ellipse should alternate between red, gree, and blue (in that order), starting back over again with red after blue. You've done this before, but this time, try to do it using an array and without using any if statements.