1 / 11

Creative Commons Attribution Non-Commercial Share Alike License

Creative Commons Attribution Non-Commercial Share Alike License. http://creativecommons.org/licenses/by-nc-sa/3.0/ Original Developer: Beth Simon, 2009 bsimon@cs.ucsd.edu. CSE8A Lecture 6. TODO: Get an interview today or tomorrow DON’T WAIT UNTIL LAST MINUTE

audra
Download Presentation

Creative Commons Attribution Non-Commercial Share Alike License

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Creative Commons AttributionNon-Commercial Share Alike License • http://creativecommons.org/licenses/by-nc-sa/3.0/ • Original Developer: Beth Simon, 2009bsimon@cs.ucsd.edu

  2. CSE8A Lecture 6 • TODO: • Get an interview today or tomorrow DON’T WAIT UNTIL LAST MINUTE • Tutor hours are listed on the web, sign up on board • Log in and have your code open in Dr. Java • Read next class: REVIEW up to 127, take the online reading quiz (there’s NEW questions). • NEW RESOURCE: http://wiki.ucsd.edu • You need to post your PSA2 on it for a point (either A or B, but B is cooler) • You can “grab” your picture to upload with screen capture. Name the file with you and your partners last names • Files with the same name “replace” each other. • Follow your grades on moodle. It’s important to keep track of how you are doing… • Labs – Score 9 or 10 • Quizzes 7-10 • PSAs 18-20 • Midterms and Final average around 73-77%

  3. CSES Meeting TONIGHT 6:30CSE B225 (basement, other side of hall) • Free pizza! • Go, get involved! • Bonfires, CSE Day, Technical Interviewing Advice, etc.! • What do YOU want to do in CSE?

  4. The Jacobs School of Engineering at the University of California, San Diego cordially invites you to attend the annual Mark and Janet (‘82) Handzel Transfer Student Reception October 15th | 5:00 – 6:30PM Powell-Focht Bioengineering Hall (PFBH) Fung Auditorium, First Floor Meet fellow engineering transfer students and learn how to get involved in research, internship, and leadership opportunities. Hors d’oeuvres served. Please RSVP with full name and PID to ess@soe.ucsd.edu Inquires: 858-534-6105 This event is sponsored through a generous gift from former transfer student and alumna Janet Handzel and husband Mark.

  5. By the end of today’s class you should be able to… • LG11: Use a for each loop in Java to loop over all pixels in a picture and perform a transformation on those pixels (e.g. decrease their red component). • LG12: Apply Java syntax to cast a variable to another value (and explain how it’s useful in setting picture colors). • LG13: Read and understand a while loop for modifying a Picture, including being able to draw a memory model of this code • LG14: Describe the single array representation of pixels in Picture.java • LG16: Find bugs in code including: a common “empty loop” bug, using the “how many times does this statement get executed” analysis technique. • LG17: Argue about the best location of a print statement to debug a problem with a loop.

  6. Clicker Quickie: • In the decreaseRed method in the book we seeWhat’s the (int)for? Pixel[] pixelArray = this.getPixels(); int value = 0; for (Pixel pO: pixelArray) { value = pO.getRed(); value = (int) (value * .5); pO.setRed(value); } Making sure value is set to a whole (int) number Doing a cast Making sure value is set to ½ of original red Rounding the calculation appropriately

  7. Solo: (60 sec) • Discuss: (2min) • Group: (30 sec) How many times is each set of code executed? Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; int index = 0; while (index < pixelArray.length) { value = pixelArray[index].getRed(); value = (int) (value * 0.5); pixelArray[index].setRed(value); index = index + 1; }

  8. Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; int index = 0; while (index < pixelArray.length) { value = pixelArray[index].getRed(); value = (int) (value * 0.5); pixelArray[index].setRed(value); } What is this code doing?:Two ways to look at it.(be able to do both) • Trace execution of the code by drawing memory to represent what is happening to variables (and how their values change) • Summarize, in a sentence that your grandmother would understand the purposeof the code • Asked as “what does this code do”? First, we need to have an idea of what our variables “look like” in memory. This involves understanding important things about the typesin the above code

  9. What is the type of the indicated variable

  10. So what are the types on variables in a _____________

More Related