CSE 113 Introduction to Computer Programming Lecture slides for Week 12 Monday, November 14 th, 2011 Instructor: Scott Settembre.

Slides:



Advertisements
Similar presentations
CISC Data Structures Ben Perry University of Delaware Summer 2011.
Advertisements

CSE 113 Introduction to Computer Programming Lecture slides for Week 3 Monday, September 12 th, 2011 Instructor: Scott Settembre.
No calculators or notes can be used on this quiz.
CSE 113 Introduction to Computer Programming Lecture slides for Week 10 Monday, October 31 th, 2011 Instructor: Scott Settembre.
CSE 113 Introduction to Computer Programming Lecture slides for Week 6 Monday, October 3 rd, 2011 Instructor: Scott Settembre.
1 Course Information Parallel Computing Fall 2008.
1 CS 177 Week 15 Recitation Slides Review. Announcements Final Exam on Sat. May 8th  PHY 112 from 8-10 AM Complete your online review of your classes.
COMP171 Data Structures and Algorithm Qiang Yang Lecture 1 ( Fall 2006)
Please open your laptops, log in to the MyMathLab course web site, and open Daily Quiz 18. You will have 10 minutes for today’s quiz. The second problem.
Games and Simulations O-O Programming in Java The Walker School
CHEMISTRY 10123/10125 Spring 2007 Instructor: Professor Tracy Hanna Phone: Office: SWR 418
CSE 113 Introduction to Computer Programming Lecture slides for Week 4 Monday, September 19 th, 2011 Instructor: Scott Settembre.
MGS 351 Introduction to Management Information Systems
Social Psychology: Attitudes & Persuasion (PSY320)
ECEN 248: INTRODUCTION TO DIGITAL DESIGN
Administrative Issues ICS 151 Winter 2010 Instructor: Eli Bozorgzadeh.
1 My Experiences as Faculty Member and Researcher Dr. Kalim Qureshi.
CSE 113 Introduction to Computer Programming Lecture slides for Week 2 Wednesday, September 7 th, 2011 Instructor: Scott Settembre.
CNS 4450 Syllabus. Context Language is a tool of thought. We rarely think without words. In solving problems by computer, we eventually get to the point.
CIS 068 Welcome to CIS 068 ! Software Design & Data Structures In JAVA Instructor: Rolf Lakaemper Peer Teacher: Aubrey Jones TA: Michael Broscius.
Welcome to CIS 2168 ! Software Design, Data Structures and Algorithms
CSE 113 Introduction to Computer Programming Lecture slides for Week 5 Monday, September 26 th, 2011 Instructor: Scott Settembre.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
1 Test Next Period Summer 3, 2015 Final Examination.
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2010.
CSE 113 Introduction to Computer Programming Lecture slides for Week 1 Monday, August 29 th, 2011 Instructor: Scott Settembre.
CSE 113 Introduction to Computer Programming Lecture slides for Week 7 Monday, October 10 th, 2011 Instructor: Scott Settembre.
CPSC 121: Models of Computation Unit 0 Introduction George Tsiknis Based on slides by Patrice Belleville and Steve Wolfman.
BIT 115: Introduction To Programming Instructor: Jon Peck
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
11 Making a Sprite Session 4.2. Session Overview  Describe the principle of a game sprite, and see how to create a sprite in an XNA game  Learn more.
Your Roadmap for Success Alice: “Would you tell me, please, which way I ought to go from here?" Cat: "That's depends a good deal on where you want to get.
Welcome to CIS 2168 ! Data Structures and Algorithms
INTRODUCTION TO PROGRAMMING ISMAIL ABUMUHFOUZ | CS 146.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2011.
CIS 068 Welcome to CIS 068 ! Software Design & Data Structures In JAVA Instructor: Rolf Lakaemper.
February ,  2/16: Exam 1 Makeup Papers Available  2/20: Exam 2 Review Sheet Available in Lecture  2/27: Lab 2 due by 11:59:59pm  3/2:
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2012.
Repetition Control Structure. Introduction Many applications require certain operations to be carried out more than once. Such situations require repetition.
CS 122 Engineering Computation Lab Lab 4 Dan De Sousa and Bruce Char Department of Computer Science Drexel University Summer 2009 ©By the author. All rights.
REMINDER: If you haven’t yet passed the Gateway Quiz, make sure you take it this week! (You can find more practice quizzes online in the Gateway Info menu.
Week 12 - Monday.  What did we talk about last time?  Defining classes  Class practice  Lab 11.
CSE 1340 Introduction to Computing Concepts Class 1 ~ Intro.
CS 367 Introduction to Data Structures Charles N. Fischer Fall s367.html.
CISC105 – General Computer Science Class 4 – 06/14/2006.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Winter 2010.
CS122 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Winter 2013.
PROBLEM SOLVING AND PROGRAMMING ISMAIL ABUMUHFOUZ | CS 170.
REMINDER: If you haven’t yet passed the Gateway Quiz, make sure you take it this week! (You can find more practice quizzes online in the Gateway Info menu.
WELCOME TO MANAGERIAL ECONOMICS MT 445 Discussion of Syllabus and Expectations in the Class.
Computer Science I ISMAIL ABUMUHFOUZ | CS 180. CS 180 Description BRIEF SUMMARY: This course covers a study of the algorithmic approach and the object.
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Prof. Jeremy.
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
CS 177 Week 15 Recitation Slides
CS122 Engineering Computation Lab Lab 3
Midterm Exam Preperation
Introduction to Data Structures
Lecture Notes – Week 3 Lecture-2
Beginning C for Engineers
Exam1 Review CSE113 B.Ramamurthy 2/16/2019 B.Ramamurthy.
Administrative Issues
February , 2009 CSE 113 B.
Midterm Review October 23, 2006 ComS 207: Programming I (in Java)
Administrative Issues
Final Review Dr. Xiaolin Hu.
Agenda for Unit 5: Control Structures
Final Exam Review CSE113 B.Ramamurthy 10/13/2019 B.Ramamurthy.
Presentation transcript:

CSE 113 Introduction to Computer Programming Lecture slides for Week 12 Monday, November 14 th, 2011 Instructor: Scott Settembre

COURSE ADMINISTRATION Section 1 Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 2

For Project Assistance You can find the up-to-date hours and locations in the “Contact” section of UBLearns. Here are the names, s, and office hours as of 11/14/2011: (Also come to additional labs if you need help) Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 3 Name addressOffice hours Bich (pronounced “Bic”) (11-11:50am) Bell 329 F (12-12:50pm) Bell 329 Troy (3-5pm) Bell 329 Scott (10-11am) Bell 232 F (10-11am) Bell 340 Also at all times by AND video conference by appointment.

You are behind the class if… If you have not: – completed chapter 1-6, then you are behind the rest of the class. – loaded the project 2 Greenfoot project and experiemented with a new AIMower class. Please do the following: – Begin working on project 2. – Start on chapter 7 in this week’s lab. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 4

Lecture and Lab this Week Lectures will go over the following: – Project 2 – switch statement – for loop Lab will have you do the following: – Start chapter 7. – Continue your project 2. – Lab Quiz on chapter 6 and Lecture notes from week 10 with for loops and switch statements. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 5

MIDTERM / FINAL EXAM / PROJECT Section 2 Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 6

Midterm exam (15%) The midterm exam will be held in lecture on October 21 st. It will cover chapters 1-6.4, including the exercises in the chapter that you do in lab. It will be a series of true/false, multiple choice, and code examination (running the code in your head), similar to the quizzes that you will have taken. Grades have been released. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 7

Final Exam (25%) The final exam will be during class during the last week of class. It will span two days, 45 minutes (or less) each day. It will consist of questions like the quizzes, as well as some code reading and understanding. More on this in November. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 8

Project 1 Project 1 grades have been posted. Good job! Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 9

Project 2 Due date: November 22 nd, 2011 at or before 11:59:59 PM We will design the abstract class we will be using in class, together. The project description will be discussed on Monday and Wednesday. The abstract class and Greenfoot project you will use will be distributed in lab. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 10

CHAPTER 6 Section 3 Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 11

The “for” loop Since counter loops are used so much, there is a quick and easy way to do them, the “for” loop. (sometimes called the “for..next” loop) Here is an example: for (int count=1; count <= 3; count++) { displayOutput("count == " + count); } displayOutput("Loop complete.“); Here is the output: count == 1 count == 2 count == 3 Loop complete. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 12

Components of a “for” loop You have the keyword “for” followed by an “expression” followed by a “statement” (or block). The expression contains 3 statements – First, a declaration or initialization that is run only once at the beginning of the loop. – Second, a Boolean expression or condition to evaluate to see if the loop should still run. – Lastly, an action to perform, usually an increment or iteration of some sort, performed at the end of the loop. “for” loops are quite nice to use as they cut down on the code clutter. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 13

Compare the “while” to “for” int count=0; while (count++ < 3) { displayOutput("count == " + count); } displayOutput("Loop complete."); for (int count=1; count < 3; count++) { displayOutput("count == " + count ); } displayOutput("Loop complete." ); Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 14

Collision Detection (not on test) Bounding-box Bounding-circle Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 15 Check each of the corners to see if it is inside another bounding box Make sure the two centers of each circle are greater than r1 + r2 away from each other

Collision Detection (not on test) Using masks – First, use bounding-boxes and determine all bounding-box collisions. – Second, take the masks from each sprite that had a bounding-box collision and see if they overlap. Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 16 It is fast to detect if rectangles overlap. It is slow to check before you set every pixel to see if it is part of the mask.

Drawing There are many Greenfoot commands that you can use to draw on the image of an Actor or the World. (Look at GreenfootImage class) Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 17

Easy way to draw on the background Get the World using getWorld() – (or if in the World class, just use “this”) Get the background image. – If in the World class, you would do use.getBackground() Draw a line. – If in an actor, you could write: getWorld().getBackground().drawLine(0,0,100,100); Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 18

Efficient Code Calling getWorld() and getBackground() each time you want to do something, can slow down performance. Try capturing the background in a private instance variable once, then using it later. – For example, in the class, make an instance variable private GreenfootImage myBackground; – Then in your constructor method or act method, you can: if (myBackground == Null) { myBackground = getWorld().getBackground(); } Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 19

Writing text // Get the background image, so we can write on it GreenfootImage scoreboard = getBackground(); // Clear what was written before scoreboard.setColor (new Color(0,153,0)); scoreboard.fillRect(0,0,120,40); // Change color to black, then write new info scoreboard.setColor(new Color(0,0,0)); scoreboard.drawString("Time: " + iterations++, 10, 10); Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 20

Objects and casting (more on this later) Objects may have more than one type! – For example, a “Dog” object is both of the “Dog” class and the “Animal” class and the “Actor” class. – If we want to make a list of Actors who are dogs and cats, we may say: List myPets; But then if one of the pets is of class “Cat”, then we will have a run-time error. Instead, we may the list like so: “List myPets;” Monday, Nov. 14th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 21