CSE 113 A. Announcements - Lab

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

CSE 113. Announcements

CSE 115. Introduction to Computer Science I

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

JAVA MOCK TEST JAVA MOCK TEST II

Loops. In Example 1, we have a Person class, that counts the number of Person objects constructed.

CSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017

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

Creating Java Programs with Greenfoot

CS/ENGRD 2110 FALL Lecture 5: Local vars; Inside-out rule; constructors

EECS 1001 and EECS 1030M, lab 01 conflict

Lecture 10. Overriding & Casting About

ISY00245 Principles of Programming. Module 7

Creating Java Programs with Greenfoot

CS 177 Week 15 Recitation Slides. Review

Programming Languages and Techniques (CIS120)

CS 177 Week 5 Recitation Slides. Loops

Programming Languages and Techniques (CIS120)

Final Exam CS 251, Intermediate Programming December 10, 2014

EECS168 Exam 3 Review

Unit 7. 'while' Loops

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

CSCI 355 LAB #2 Spring 2004

CS/ENGRD 2110 SPRING Lecture 5: Local vars; Inside-out rule; constructors

CSE115 Lab 2 Fall 2016

Announcements. 1. Forms to return today after class:

CSE 115 / 503 INTRODUCTION TO COMPUTER SCIENCE I. Dr. Carl Alphonce Dr. Jesse Hartloff

Lecture 9: Lists. MIT-AITI Kenya 2005

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

Announcements. CS18000: Problem Solving And Object-Oriented Programming

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM

1.00/1.001 Tutorial 1

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

Goal. Generic Programming and Inner classes. Minor rewrite of linear search. Obvious linear search code. Intuitive idea of generic linear search

Le L c e t c ur u e e 3 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Control Statements

Assertions, pre/postconditions

CSCI 355 Lab #2 Spring 2007

Computer Science 210: Data Structures

CS 11 java track: lecture 1

Arrays Classes & Methods, Inheritance

CS/ENGRD 2110 FALL Lecture 6: Consequence of type, casting; function equals

Inheritance and Interfaces

Mathematics/Science Department Kirkwood Community College. Course Syllabus. Computer Science CSC142 1/10

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

University of Massachusetts Amherst, Electrical and Computer Engineering

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

Announcements for the Class

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes

The Java language has a wide variety of modifiers, including the following:

CSE115 Introduction to Computer Science for Majors I Spring 2008 Final Exam. First/Given Name (PRINT) May 6, 2008

C++ Important Questions with Answers

CSE : Python Programming

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

CS 180 Final Exam Review 12/(11, 12)/08

Bjarne Stroustrup. creator of C++

Haskell Review COMP360

Repetition Structures

CS/ENGRD 2110 FALL Lecture 7: Interfaces and Abstract Classes

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

CMSC 132: Object-Oriented Programming II

CS/ENGRD 2110 SPRING 2018

Inf1-OP. Inf1-OP Exam Review. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 20, School of Informatics

CIS 130 Exam #2 Review Suggestions

CSE143 Exam with answers MIDTERM #1, 1/26/2001 Problem numbering may differ from the test as given.

Lecture 2: Variables & Assignments

CS-202 Introduction to Object Oriented Programming

School of Computer Science CPS109 Course Notes 6 Alexander Ferworn Updated Fall 15. CPS109 Course Notes 6. Alexander Ferworn

Loops. CSE 114, Computer Science 1 Stony Brook University

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

1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005

COMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal

Inf1-OOP. OOP Exam Review. Perdita Stevens, adapting earlier version by Ewan Klein. March 16, School of Informatics

8/27/13. An intro to programming* *Java. Announcements. Professor Rodger. The Link. UTAs start TONIGHT!

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I

Review: Object Diagrams for Inheritance. Type Conformance. Inheritance Structures. Car. Vehicle. Truck. Vehicle. conforms to Object

Code Reuse: Inheritance

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

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

About this exam review

Programming with Java

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java

Collections, Maps and Generics

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

BINARY SEARCH TREES CS 200 RECITATION 7

If you don t, it will return the same thing as == But this may not be what you want... Several different kinds of equality to consider:

CS/ENGRD 2110 SPRING 2018

Tips from the experts: How to waste a lot of time on this assignment

Constants are named in ALL_CAPS, using upper case letters and underscores in their names.

1 Inheritance (8 minutes, 9 points)

CS171:Introduction to Computer Science II

Lecture 02, Fall 2018 Friday September 7

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

Administration. Conditional Statements. Agenda. Syntax. Flow of control. Lab 2 due now on floppy Lab 3 due tomorrow via FTP

Lecture Set 4: More About Methods and More About Operators

CS121/IS223. Object Reference Variables. Dr Olly Gotel

Transcription:

CSE 113 A February 21-25, 2011 Announcements - Lab Lab 1, 2, 3, 4; Practice Assignment 1, 2, 3, 4 grades are available in Web-CAT look under Results -> Past Results and if looking for Lab 1, make sure to check closed. Lab 5 & Practice Assignment 5 will be graded by Web-CAT, but the grading is not functional at this time. 1

Announcements Practical Exam 1 This week in recitation. You MUST attend your registered recitation during that week to be allowed to take the exam. If you are not sure which recitation you are registered for, check the UBLearns Gradebook. Information about the practical exam is available as a link off of the Schedule page. Announcements Exams Exam 1 Returned Monday in lecture pick up from me if you did not already do so. Exam 2 Monday, March 7 th in lecture Review for Exam 2 on Friday, March 4 th. Look for review sheet to be posted on the Schedule page on or about February 25 th. 2

Constructors Constructors are special methods that are called every time an object is created they set up the initial state of our objects. Explicit constructors (ones that you can see in the source code) look like this: public NameOfClass() 5 Constructors A constructor has the same name as the name of the class. It does not have a return type. If there is no explicit constructor in the source code for a class, Java provides an implicit one that you do not see in the source code, but is inserted at compile time. 6 3

CarWorld Class Looking at the constructor of CarWorld, we can see a method call that looks like this: super(x, y, z) Here, we are not calling a method called super, but rather super is a keyword that indicates the superclass. In this case, we are calling the superclass constructor. 7 Adding objects at startup We can add objects to the world when it is created by calling the addobject method from the world. Example addobject(new Car(), 34, 56); Note that we need to create a new Car object to add by using the expression new Car(). This expression creates an object and calls the constructor of that object. The numbers that follow are the x and y coordinates of where we would like the object to be in the world. 8 4

9 Variables Variables are used to store information. Instance variables store information important to the entire class. 10 5

Declaring an Instance Variable private type identifier; type: The type of information the variable stores. identifier: Name for the variable picked by the programmer. 11 More notes on instance variables This code goes inside of the class body, but outside of any methods. Once we declare an instance variable, it is good practice to initialize it. We initialize in the constructor. 12 6

Assignment variablename = expression; The expression on the right is evaluated first and then the result is stored in the variable named on the left. 13 If-statements We have been working a lot with if-statements to determine choices in our programs. If we look at our program execution with if-statements, it would look something like this: 14 7

More ways to choose We could create choice in programs that looks like this: 15 More ways to choose That would be the notion of a choice when there is a definitive path when a condition is true and another path when the condition is false. In order to do this type of choice in code, we would need to use if-else statements instead of just ifstatements. 16 8

If-else Syntax if( /*boolean expression*/ ) //code to be executed if boolean expression is true else //code to be executed if boolean expression is false 17 Loops Repetition in programs allows us to repeat something over and over. We achieve repetition through loops. We will look at a while loop to help us repeat. 18 9

While-loop This will keep looping until the condition indicated on the loop is false. while (/*booleanexpression*/) //code that should be repeated 19 While-Loops while (true) //code that should be repeated This loop will continue forever because true is always true. Infinite loops like this do not get along with Greenfoot. 20 10

While-Loop In order to help us keep track of how many times we are looping, we need to create a variable to store a count. Inside the loop, we also must remember to increment the count so that the loop executes the correct number of times. 21 While-Loops int count = 0; while (count < 10) //code that should be repeated count = count + 1; The code in this loop will execute 10 times 22 11