90 likes | 180 Vues
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.
E N D
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 notenough; you are responsible for all material covered in the lecture notes.
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
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)
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? PImageimg=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);
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?
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.
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; }
Classes and Objects • Explain the relationship between an object and a class. • Study the Spotclass 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?