CSE 113 Introduction to Computer Programming Lecture slides for Week 7 Monday, October 10 th, 2011 Instructor: Scott Settembre.

Slides:



Advertisements
Similar presentations
CSE 113 Introduction to Computer Programming Lecture slides for Week 3 Monday, September 12 th, 2011 Instructor: Scott Settembre.
Advertisements

CSE 113 Introduction to Computer Programming Lecture slides for Week 10 Monday, October 31 th, 2011 Instructor: Scott Settembre.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Abstract Classes and Interfaces The objectives of this chapter are: To explore the concept of abstract classes To understand interfaces To understand the.
CSE 113 Introduction to Computer Programming Lecture slides for Week 6 Monday, October 3 rd, 2011 Instructor: Scott Settembre.
ITEC200 – Week03 Inheritance and Class Hierarchies.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
Wednesday, 10/2/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/2/02  QUESTIONS (on HW02 – due at 5 pm)??  Today:  Review of parameters  Introduction.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Lecture 17 Abstract classes Interfaces The Comparable interface Event listeners All in chapter 10: please read it.
Reviews for Exam 1 Chapter 1-4 CS 211 Data Structures MHC, 2007.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
Chapter 101 Dynamic Data Structures and Generics Chapter 10.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
C++ Classes in Depth. Topics Designing Your Own Classes Attributes and Behaviors Writing Classes in C++ Creating and Using Objects.
CSC 171 – FALL 2004 COMPUTER PROGRAMMING LECTURE 0 ADMINISTRATION.
Slide 1. Slide 2 Administrivia Nate's office hours are Wed, 2-4, in 329 Soda! TA Clint will be handing out a paper survey in class sometime this week.
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
CS 106 Introduction to Computer Science I 04 / 13 / 2007 Friday the 13 th Instructor: Michael Eckmann.
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
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
CSE 113 Introduction to Computer Programming Lecture slides for Week 2 Wednesday, September 7 th, 2011 Instructor: Scott Settembre.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
CSE 113 Introduction to Computer Programming Lecture slides for Week 5 Monday, September 26 th, 2011 Instructor: Scott Settembre.
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
PHY 1405 Conceptual Physics (CP 1) Spring 2010 Cypress Campus.
CSE 113 Introduction to Computer Programming Lecture slides for Week 1 Monday, August 29 th, 2011 Instructor: Scott Settembre.
Principles of Computer Science I Honors Section Note Set 1 CSE 1341 – H 1.
CSE 113 Introduction to Computer Programming Lecture slides for Week 12 Monday, November 14 th, 2011 Instructor: Scott Settembre.
Agenda Object Oriented Programming Reading: Chapter 14.
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.
Please CLOSE YOUR LAPTOPS, and turn off and put away your cell phones, and get out your note- taking materials.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Chapter 5 Objects and Classes Inheritance. Solution Assignments 3 & 4 Review in class…..
CS 61B Data Structures and Programming Methodology July 2, 2008 David Sun.
Arithmetic, Class Variables and Class Methods Week 11
Lecture 3 Introduction to Computer Programming CUIT A.M. Gamundani Presentation Layout from Lecture 1 Background.
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.
Classes, Interfaces and Packages
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
CSE 1340 Introduction to Computing Concepts Class 1 ~ Intro.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter 2012.
OOP Basics Classes & Methods (c) IDMS/SQL News
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.
CSE Wireless and Adhoc networks Instructor: Ayman Alharbi Computer Engineering Dept. (Head of dept. ) Why ?
WELCOME TO MICRO ECONOMICS AB 224 Discussion of Syllabus and Expectations in the Class.
Spring 2008 Mark Fontenot CSE 1341 – Honors Principles of Computer Science I Note Set 1 1.
Computer Science I ISMAIL ABUMUHFOUZ | CS 180. CS 180 Description BRIEF SUMMARY: This course covers a study of the algorithmic approach and the object.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
CSc 020: Programming Concepts and Methodology II
Interlude 2 - The Greeps Competition
EKT 472: Object Oriented Programming
About the Presentations
September 27 – Course introductions; Adts; Stacks and Queues
Phil Tayco Slide version 1.0 Created Nov. 26, 2017
Introduction to Data Structures
Data Structures and Algorithms for Information Processing
Abstract Classes and Interfaces
Review of Previous Lesson
Abstract Classes and Interfaces
New Student Orientation
Chapter 1-4 CSc 212 Data Structures, Sec FG CCNY, 2009
Presentation transcript:

CSE 113 Introduction to Computer Programming Lecture slides for Week 7 Monday, October 10 th, 2011 Instructor: Scott Settembre

COURSE ADMINISTRATION Section 1 Monday, Oct. 10th, 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 10/10/2011: (Also come to additional labs if you need help) Monday, Oct. 10th, 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-5, then you are behind the rest of the class. – made significant progress on your project, then you are behind the rest of the class. – experienced how to construct an “if” statement or a “while” statement, then you are going to have problems on the test. Please do the following: – Complete chapter 1-5 in Bell 101. – Finish your project by Friday. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 4

Lecture and Lab this Week Lectures will go over the following: – Chapter 6 concepts Abstract classes Overloading method names The keyword “this” – referring to the current object Shared variables – use of the keyword “static” Constants – use of the keyword “final” Lab will have you do the following: – Finish completely chapters 1-5 if you haven’t – Finish your Project 1 – Begin chapter 6 up to and including 6.4 – Lab Quiz on chapters 1-5 (not 6) Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 5

MIDTERM / FINAL EXAM / PROJECT Section 2 Monday, Oct. 10th, 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. Monday, Oct. 10th, 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 may span two days (I may give half on one day and half the next day). It will consist of questions like the quizzes, as well as some code reading and understanding. More on this in November. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 8

Project 1 Due date: October 14 th, 2011 at or before 11:59:59 PM Get’r done! Submit appropriately, using the steps outlined in the Course Documents – Submission Steps.pdf file. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 9

CHAPTER 6 Section 3 Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 10

The “double” type A “double” type is declared like so: double pi;// pi is declared as a floating point number pi = ;// pi now equals It can be a value that ranges between a negative and positive range of numbers. – Typically, it is any 7 place decimal number between and You can set its initial value when you declare it: double pi = ;// pi declared & set to Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 11

What is an “abstract” class? A class that you cannot make an instance (i.e. an object) from. Why? – Well, the code acts more like an “outline” or a summary, but has no real substance. – It is meant to get you started with your sub-class, providing you with some code, some method names, and some instance variables. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 12

The abstract keyword You can always tell if a class is an abstract class, by looking at the class signature: Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 13 import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot) /** * A variation of an actor that maintains precise location (using doubles for the co-ordinates * instead of ints). It also maintains a current movement in form of a movement vector. * Poul Henriksen Michael Kolling */ public abstract class SmoothMover extends Actor { private Vector movement; private double exactX; private double exactY; public SmoothMover() … This abstract keyword indicates that this class can only be a super-class of other classes, it cannot be instanced into an object.

Abstract class example Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 14 Actor Vehicle Car Boat Bicycle Abstract class. Code from this class can only be used from a subclass.

Why can’t you make an instance out of “Vehicle” then? Well, if you look at the “vehicle” code, you will probably not find anything specific about a specific type of vehicle. Instead, you will find generic methods and instance variables like “move”, “wheels”, or “getPassengerList”. Creating an object out of that, may not make any sense because you can’t ask the object to “do” anything. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 15

Let’s look at another class The “Car” class has a constructor: Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 16 public class Car extends Vehicle { private int wheels; private int color; public Car() { wheels = 4;// Default to 4 wheels color = 0;// Default to color ‘0’ – which == black } This is called the “default constructor” of a class. It has no parameters in the parameter list.

What is “overloading”? When you write two or more methods that use the SAME name, you are overloading a method. When you “overload” a method, – You use the same name as an already defined method. – You must change the parameter list so the compiler knows which method definition to use. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 17

Why should we overload? It is a useful technique, so that you can use the same code. It allows you to “ask” or “command” the object the same thing, in different ways. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 18

Overloading example Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 19 public class Car extends Vehicle { private int wheels; private int color; public Car() { wheels = 4;// Default to 4 wheels color = 0;// Default to color ‘0’ } public Car ( int initialColor ) { wheels = 4; color = initialColor; } Notice that the method has the same name, but the parameter list is different. This means, you can initialize the car two different ways: 1.either by giving no information to the constructor, or 2.by giving color information to the constructor.

Let’s take a different look at this example Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 20 public class Car extends Vehicle { private int wheels; private int color; public Car() { wheels = 4;// Default to 4 wheels color = 0;// Default to color ‘0’ } public Car ( int color ) { wheels = 4; color = color; } I have changed the name from “initialColor” to “color”. Now how will the compiler know which color I am referring to? The “color” from the paramter list or the private instance “color”?

The this keyword There is a keyword called this, which allows the code to refer to the current object running. Remember, if you have more than one object of a specific class, each object runs the SAME code, but has different instance variables. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 21

Bunch of cars Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 22 Car 1 wheels = 4 color = 0 Car 2 wheels = 4 color = 255 Car 3 wheels = 4 color = 59 All these private instance variables values exist in memory at different locations, but the constructor code exists in only one location. public Car () {…} Public Car (int color) {…} So if we are in this code here, how do we know where to put the “color” value?

Using this keyword Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 23 public class Car extends Vehicle { private int wheels; private int color; public Car() { wheels = 4;// Default to 4 wheels color = 0;// Default to color ‘0’ } public Car ( int color ) { wheels = 4; this.color = color; // Assign color to the instance variable. } Now how will the compiler know which color I am referring to? “this.color” refers to the current object’s instance variable, whereas the “color” is the “color” value from the parameter list of the method.

Another use of this this can also be used to call the constructor of a class. – Yes, I know I told you that you cannot call the constructor of a class, except once at the creation of the object, but this is an exception. – You must call it from within an overloaded constructor, thus it really is a constructor calling a constructor. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 24

Using this keyword to call a constructor Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 25 public class Car extends Vehicle { private int wheels; private int color; public Car() { this (0);// call the Car overloaded constructor with default value for color } public Car ( int color ) { wheels = 4; // Default to 4 wheels this.color = color; // Assign color to the instance variable. } The default constructor will now call the overloaded constructor with a default value for color.

PREVIEW FOR PROJECT 2 Section 4 Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 26

Project 2 - Discussion I’ll release the description of project 2 on Monday and I will discuss it in class. Project 2 will further explore your programming skills, but more importantly, it will show you the power of Object Oriented Programming (OOP) You don’t need a CS degree to work magic! Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 27

Micro-mouse Competitions Academic based competitions to encourage autonomous robot development. Here are some links: – Very fast final solution run: ature=related ature=related – Shows learning phase the final solution run: ure=related ure=related Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 28

DARPA Grand Challenge The DARPA Grand Challenge is a government prize-backed challenge to encourage development of autonomous vehicles. Autonomous vehicles are vehicles that can drive on their own, WITHOUT human supervision. This is different than Remotely Operated Vehicles (ROV), in that ROV’s have humans remotely telling the aircraft what to do. Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 29

DARPA Grand Challenge Videos challenge rules explained :45 is hardware review, you can skip. is a good background explanation of what the challenge had. Good vehicle video. – No voiceover, pure video caps. – Team Buffalo!!! Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 30

What will you need to do? Stay tuned and find out on Monday! Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 31

Robotic Car – Think about it Monday, Oct. 10th, 2011 University at Buffalo: CSE 113 Instructor: Scott Settembre 32 Actor Robot RobotCar Sensor BumpSensor