Creative Commons Attribution Non-Commercial Share Alike License

Slides:



Advertisements
Similar presentations
1 CS 201 Compiler Construction Software Pipelining: Circular Scheduling.
Advertisements

Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Peer Instruction for the First Time: Experiences of a First Time User in Computer Science Beth Simon Computer Science and Engineering University of California,
Workshop on Peer Instruction: Making Good Clicker Questions Beth Simon Computer Science and Engineering University of California, San Diego Credits: Sara.
CSE 8A Lecture 8 Reading for next class: None Prepare for In-term exam 2 PSA4: Collage and Picture Flip, DON’T WAIT (it’s longer than the previous PSAs)
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Using a Debugger. SWC What is ”debugging”? An error in a computer program is often called a ”bug”… …so, to ”debug” is to find and get rid of errors in.
NestedLoops-part11 Nested Loops – part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CSE8A Lecture3 TODO: –Finish PSA1 individually (no partner!) and turn it in with the bundlePSA1 command GET AN INTERVIEW for PSA1 from a tutor See tutor.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Georgia Institute of Technology Manipulating Pictures, Arrays, and Loops Barb Ericson Georgia Institute of Technology August 2005.
TOPIC 6 MODIFYING PICTURES USING LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
1 BUILDING JAVA PROGRAMS CHAPTER 2 Pseudocode and Scope.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CPSC1301 Computer Science 1 Chapter 4 Manipulating Pictures, Arrays, and Loops part 5.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CSE8A Lecture 5 TODO: –FINISH PSA2 WITH YOUR PARTNER! Read next class: Section 5.1. PLAY WITH CODE! –Get stuck, then figure out how to get unstuck – it’s.
ITEC 370 Lecture 18 Testing. Review Questions? Design document due W –System can be implemented just by following it Implementation –Methods (prototype,
ManipulatingPictures-part31 Manipulating Pictures, Arrays, and Loops part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 2 Barb Ericson Georgia Institute of Technology August 2005.
Arrays. What is an array? An array is a collection of data types. For example, what if I wanted to 10 different integers? int num1; int num2; int num3;
Recursion Powerful Tool
Barbara Ericson Georgia Tech Sept 2005
AP Java Elevens Lab.
I/O Streams File I/O 2-D array review
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
Topic 6 Modifying Pictures Using Loops
CSE 8A Lecture 17 Reading for next class: None (interm exam 4)
Manipulating Pictures, Arrays, and Loops part 3
Testing and Debugging.
Functions, locals, parameters, and separate compilation
Programming Abstractions
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops part 5
Two-Dimensional Arrays and Nested Loops – part 2
CSE 8A Lecture 6 Reading for next class:
Arrays in Java What, why and how Copyright Curt Hill.
Programming Abstractions
Manipulating Pictures, Arrays, and Loops part 3
Creative Commons Attribution Non-Commercial Share Alike License
Two-Dimensional Arrays and Nested Loops – part 2
Homework Any Questions?.
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops
Arrays.
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops part 6
Creative Commons Attribution Non-Commercial Share Alike License
Creative Commons Attribution Non-Commercial Share Alike License
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops part 6
Chapter 2 Lecture 2-3: Loop Figures and Constants reading:
Presentation transcript:

Creative Commons Attribution Non-Commercial Share Alike License Original Developer: Beth Simon, 2009 bsimon@cs.ucsd.edu

CSE8A Lecture 9 Read next class: read pg Finish PSA2! Get an interview before Thurs! Advice on PSAs from the tutors Read over the WHOLE PSA specification before you start coding Figure out which methods in which files you will write Next figure out the signature (return type, name, parameters) Know how this method will be called Know what your output should look like (check with others) Compile every couple of lines (makes finding bugs easier) READ THE SPECIFICATION WITH SUPER FINE ATTENTION! Specifications are “specific” and detail exactly how things must be done Software Development is a “team effort” which is managed by specifications

By the end of today’s class you should be able to… LG19: Read and trace execution of a code with a for loop (using a single array of pixels). LG20: Find and fix array index out of bounds exceptions in a for loop LG21: Read and trace execution of a nested loop that loops over a Picture object LG22: Read and code nested loops to perform mirroring (and related) transformations using nested loops.

How many times is each set of code executed? Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; for(int index = 0; index < pixelArray.length; index++); { p = pixelArray[index]; value = p.getRed(); value = (int) (value * 0.5); p.setRed(value); }

What picture most accurately describes what this code does ? DO NOT SHOW RESULTS: ISOMORPHIC NEXT Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; for(int index = 0; index < pixelArray.length-1; index++) { p = pixelArray[index]; q = pixelArray[index+1]; p.setRed(q.getRed()); p.setBlue(q.getRed()); p.setGreen(q.getGreen()); }

What picture most accurately describes what this code does ? Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; for(int index = 0; index < pixelArray.length-1; index++) { p = pixelArray[index+1]; q = pixelArray[index]; p.setRed(q.getRed()); p.setBlue(q.getRed()); p.setGreen(q.getGreen()); }

Why does this code have an error? Pixel[] pixelArray = this.getPixels(); Pixel p, q; for(int index = 0; index < pixelArray.length; index++) { p = pixelArray[index]; q = pixelArray[index+1]; p.setRed(q.getRed()); p.setBlue(q.getRed()); p.setGreen(q.getGreen()); } It tries to access pixelArray[-1] It tries to access pixelArray[0] It tries to access pixelArray[pixelArray.length] It tries to access pixelArray[pixelArray.length+1] None of the above

Fill in the code to loop over pixels in THIS ORDER UP question: 2 min Fill in the code to loop over pixels in THIS ORDER (bottom right to top left) Pixel[] pixelArray = this.getPixels(); for ( ) { //Some code doing set on pixelArray[index] }