CSE 113. Announcements

Similar documents
CSE 113 A. Announcements - Lab

Creating Java Programs with Greenfoot

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

Improving the Crab more sophisticated programming

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

Announcements - Grades UBLearns grades just updated Monday, March 28 th (11:00am). Please check grades.

CSCI 355 LAB #2 Spring 2004

AP Computer Science Summer Work Mrs. Kaelin

CS313T ADVANCED PROGRAMMING LANGUAGE

CSE 326 Team. Today s Outline. Course Information. Instructor: Steve Seitz. Winter Lecture 1. Introductions. Web page:

University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner

Survey #2. Programming Assignment 3. Final Exam. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu.

Announcements. Lab 03 inbase late submissions Midterm #1 Friday. Project 2 is posted. Covers everything through basics of OOP

Inheritance and Interfaces

CS18000: Problem Solving And Object-Oriented Programming

Object Fundamentals Part Three. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 4 09/06/2007

Marking Period 1. Marking Period 2

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120)

MORE OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 4 09/01/2011

QUIZ 2 Introduction to Computer Science (COMP 250) Mon. March 2, 2009 Professor Michael Langer

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

OOP in Java Review. CS356 Object-Oriented Design and Programming October 1, 2014

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Inheritance. CSE 142, Summer 2002 Computer Programming 1.

CS Week 15 Page 1

CSC148H Week 1 >> COURSE INFORMATION, RECAP, OOP. Sadia Rain Sharmin Week of May 7, 2018

Lecture 1: CSE 373. Data Structures and Algorithms

Improving the crab: more sophisticated programming

CSE 240 Introduction to Computer Architecture

Maximization and Minimization Problems. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington

Lecture 3. Wednesday, September 3, 2014

Sorting. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1

More OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 4 09/11/2012

Outline. Announcements. Homework 2. Boolean expressions 10/12/2007. Announcements Homework 2 questions. Boolean expression

Introduction to Programming (Java) 4/12

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Submitting Assignments

Barchard Introduction to SPSS Marks

Classical Internet Applications

Announcements. Reading Material. Recap. Today 9/17/17. Storage (contd. from Lecture 6)

Final Exam. Programming Assignment 3. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

Darrell Bethea June 6, 2011

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

Control Statements. if for while

2. The object-oriented paradigm!

Barchard Introduction to SPSS Marks

INHERITANCE AND TYPE HIERARCHIES. Prof. Chris Jermaine

Basic Class Diagrams. Class Diagrams, cont d. Class Diagrams, cont d. Car. Car. Car. What does the minus sign here mean?

Software Design and Analysis for Engineers

COMP 401 COURSE OVERVIEW

CSCI 136 Data Structures & Advanced Programming. Lecture 13 Fall 2018 Instructors: Bill 2

2. The object-oriented paradigm

EECS 183 Week 8 Diana Gage. www-personal.umich.edu/ ~drgage

Week 7. Statically-typed OO languages: C++ Closer look at subtyping

} Each object in a Java program has an identifier (name) } This includes:

CSE 115. Introduction to Computer Science I

What Is In the MsgBox?

C++ Inheritance and Encapsulation

Greenfoot! Introducing Java With Games And Simulations. Workshop material. Wombats. Object Orientation. Asteroids, Ants and other creatures.

Final Exam. Programming Assignment 3. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

CSCI 355 Lab #2 Spring 2007

Example Program. public class ComputeArea {

INTERFACES IN JAVA. Prof. Chris Jermaine

MySQL: an application

Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Fall Semester, Introduction to EECS 2

9/19/2018 Programming Data Structures. Polymorphism And Abstract

Nortel Networks Integrated Call Director

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues

Object-Oriented ProgrammingInheritance & Polymorphism

Inheritance and Interfaces

Object Oriented Programming and Design in Java. Session 10 Instructor: Bert Huang

CS11 Introduction to C++ Fall Lecture 7

CS61B - Exam 2 March 17, Consider the following example of a program that uses inheritance.

The JavaBars Microworld: Basic Features and Examples Heide G. Wiegel John Olive The University of Georgia

Lecture 26: Sorting CS 1110 Introduction to Computing Using Python

CS 61B Data Structures and Programming Methodology. July 2, 2008 David Sun

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

Programming overview

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

CPSC 213. Introduction to Computer Systems. About the Course. Course Policies. Reading. Introduction. Unit 0

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

DCS/100: Procedural Programming

CSC209. Software Tools and Systems Programming.

CS 112 Project Assignment: Visual Password

Survey #2. Variable Scope. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings. Scope Static.

In Java, to create a class named "B" as a subclass of a class named "A", you would write

Exam 1 Recursion, Induction, and Object-Oriented Programming

Bjarne Stroustrup. creator of C++

Computer Grade 5. Unit: 1, 2 & 3 Total Periods 38 Lab 10 Months: April and May

BINARY SEARCH TREES CS 200 RECITATION 7

CSE 70 Final Exam Fall 2009

The C++ Object Lifecycle. EECS 211 Winter 2019

Algorithms & Datastructures Laboratory Exercise Sheet 1

Media Computation. Lecture 16.1, December 8, 2008 Steve Harrison

Git Setup Help using GitKraken (CSE 154)

Lecture 10. Finding strongly connected components

Programming Languages and Techniques (CIS120)

Transcription:

CSE 113 September 20, 2010 Lab 3 posted Announcements Grades for all labs are still not being computed because of problem with Web-CAT s grading module hopefully we will get to a resolution this week Exam 1 Review Wednesday (review sheet posted on website) Exam 1 Friday 1

Car Example from class Let s look at the code for the Car class and discuss parts of it. I ve added stuff as well. 2

What happens every time act is called? First, we check if we are at the edge of the world. If so, we turn. Then, get a random number. If it is less than 20, we turn again. Third, check if the user has pushed the left arrow key, if so, we turn. Fourth, we move. Fifth, we check to see if we can see a Barrel. If we can, we destroy it. Method definition vs Method call Where are they in the slide? 3

4

Where do the methods come from? Ourselves (the class itself can have its own methods) Our parent class (superclass) A superclass of our superclass (continue up the hierarchy) An outside class How can we tell what is from where? If it is a method inside the same class, there will be a method definition for it in the class body. If it belongs to our parent or another superclass in the hierarchy, we can find out by looking at the documentation for the superclasses or in the pull-out method menus from inside the world. If its from an outside class, we will need to specify the class name with a. in front of the name of the method 5

No methods called that internal to this class there are no other methods in this class except act. From an outside class note the Greenfoot. before each one. 6

That means the rest of these are inherited from our superclasses. Writing additional methods Probably a good idea to break up our code into methods. Better for organization Better for readability Helps to reduce errors 7

Writing additional methods Take each piece of the act method and break it into it s own method. When complete, act will simply be a series of method calls. 8

private void checkforedges() { Important Note The line up top is now empty that s where the code from the method used to be. Is that okay? 9

Well. If you want the method you wrote to never be called, then it is fine. However, if we actually want to check for edges of the world, we need to put in a method call to the new method we just wrote. checkforedges(); private void checkforedges() { 10

public vs private Note that in the method we just put in, it started with private not public why? public vs private If we are making a method that will only be used within the class, we keep it private, that way no one else is able to call it. If you make a method public, any other object can call that method* OK, that s not quite true, but it will suffice for now until we learn about some other things. 11

checkforedges(); randomturn(); private void checkforedges() { private void randomturn() { checkforedges(); randomturn(); checkkeypressed(); private void checkforedges() { private void randomturn() { private void checkkeypressed() { 12

checkforedges(); randomturn(); checkkeypressed(); checkforbarrel(); private void checkforedges() { private void randomturn() { if(greenfoot.getrandomnumber (100) < 20) { turn(greenfoot.getrandomnumber (181) 90); private void checkkeypressed() { if(greenfoot.iskeydown( left )) { private void checkforbarrel() { So, in the end act is: checkforedges(); randomturn(); checkkeypressed(); checkforbarrel(); 13