test 2 review

9
Test 2 Review

Upload: leo-shannon

Post on 31-Dec-2015

20 views

Category:

Documents


0 download

DESCRIPTION

Test 2 Review. General Info. All tests are comprehensive . You are still responsible for the material covered prior to the first exam. You will be tested more on your ability to understanding code than on your ability to write code. There will be multiple choice and true/false questions. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Test 2 Review

Test 2 Review

Page 2: Test 2 Review

General Info.• All tests are comprehensive. You are still

responsible for the material covered prior to the first exam.

• You will be tested more on your ability to understanding code than on your ability to write code.

• There will be multiple choice and true/false questions.

• Studying this review is not enough; you are responsible for all material covered in the lecture notes.

Page 3: Test 2 Review

Topics covered since last exam

• Writing and calling functions• Manipulating images and text on the canvas• Creating Interactive programs

– Mouse and keyboard event handler functions– Mouse and keyboard built-in variables

• Using the functions:loop(), noLoop(), and reDraw()• Using arrays• Creating object orientated programs using classes

and objects

Page 4: Test 2 Review

Writing and calling functions• Questions 7-9 from exam 1.• Study the program targets.pde and answer the

questions below.• What will be drawn by this program?• How many parameters does the function

drawTarget() have?• Is there anything wrong with calling the

function drawTarget() as shown below. drawTarget(100, 100, 100);

• What does the word void mean in the function definition:void drawTarget(int xloc, int yloc, int outerDia, int numCircles)

Page 5: Test 2 Review

Manipulating images and text• If the color depth of an image format is 8 bits, how many

distinct colors can be represented?• Name one image format that provides lossless

compression and one that provides lossy compression.• Does this command cause an image (that is stored in

the sketch data folder) to appear on the canvas?

PImage img=loadImage(“cartoonFace.gif");

• Describe the difference between the data type String and the data type char.

• Is this a legal statement in Processing: ‘5’ + 5 ;• What is printed by this statement:

println(boolean(5)) ;• Does this command cause text to appear on the canvas:

PFont f = loadFont("Albany-48.vlw“, 40);

Page 6: Test 2 Review

Creating Interactive programs

• Compare and contrast the programs mousey.pde and mousePressed.pde, and answer the questions below.

– Which program contains an event handler?

– Do the programs respond to user inputs differently? Explain the differences; be specific.

– How is the function mousePressed() called?

– What values are stored in the variables mouseX, mouseY?

Page 7: Test 2 Review

Functions: loop(), noLoop(), and reDraw()

• Study the program loopNoLoop.pde and answer the questions below.– Does the program contain any event

handlers, and if so how many?– Explain exactly what the program does

when it’s running and the user interacts with the program by: (1) pressing a key on the keyboard, or (2) pressing a mouse button.

Page 8: Test 2 Review

Arrays• Declare an array large enough to hold

100 float variables.

• Declare an array of 10 integers and store the value 1 in each element in the array.

• Explain what happens when the following segment of code is run.float[] coswave = new float[100];

for (int i = 0; i < 100; i++) {

coswave[i] = i;

}

Page 9: Test 2 Review

Classes and Objects• Explain the relationship between an object

and a class.• Study the Spot class and the program

ExplodingSpots that uses that class. Answer the questions below. – Identify the Spot class constructor.– Identify a line of code in which that constructor is

called.– Identify a line of code in which a Spot object is

created.– How many data members does the Spot class

have?