Announcements & Review

Slides:



Advertisements
Similar presentations
Overloading Having more than one method with the same name is known as overloading. Overloading is legal in Java as long as each version takes different.
Advertisements

Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
JAVA Revision Lecture Electronic Voting System Marina De Vos.
1 Todays Objectives Announcements Homework #1 is due next week Return Quiz 1 – answers are posted on the Yahoo discussion page site Basic Java Programming.
1 Chapter 11 Introducing the Class Pages ( )
Lecture 9: More on objects, classes, strings discuss hw3 assign hw4 default values for variables scope of variables and shadowing null reference and NullPointerException.
Lecture 19: Reading Input from Files Announcements & Review Lab 6 Due Thursday arrays of objects more flight reservations Last time: static methods vs.
Lecture 28: Abstract Classes & Inheritance Announcements & Review Lab 8 Due Thursday Image and color effects with 2D arrays Read: –Chapter 9 Cahoon & Davidson.
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
Lecture 17 Abstract classes Interfaces The Comparable interface Event listeners All in chapter 10: please read it.
Looking inside classes Choices Week 4. Class bodies contain fields, constructors and methods. Fields store values that determine an object’s state. Constructors.
1 Objects and Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in Objects Reading for this Lecture:
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
Objects Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
Understanding class definitions – Part II –. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main.
Programming with Collections Grouping & Looping - Collections and Iteration Week 7.
Understanding class definitions Looking inside classes.
Constructors A constructor is a method that creates an object in Java. It does not return anything and it is not void. It’s only purpose is to create an.
CS1101: Programming Methodology Aaron Tan.
Week #2 Java Programming. Enable Line Numbering in Eclipse Open Eclipse, then go to: Window -> Preferences -> General -> Editors -> Text Editors -> Check.
Introduction to Object-Oriented Programming
Passing Other Objects Strings are called immutable which means that once a String object stores a value, it never changes –recall when we passed a message.
Arrays Chapter 8. What if we need to store test scores for all students in our class. We could store each test score as a unique variable: int score1.
Agenda Object Oriented Programming Reading: Chapter 14.
ECE122 Feb. 22, Any question on Vehicle sample code?
CS 100Lecture 131 Announcements Exam stats P3 due on Thursday.
Lecture 7: Whiles - Indefinite Loops Input and while loops Katie Coons CS 305J February 2, 2007.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Classes. Student class We are tasked with creating a class for objects that store data about students. We first want to consider what is needed for the.
CS100A, Fall 1998 Key Concepts 1 These notes contain short definitions of the basic entities that make up a Java program, along with a description of the.
1.Reading from Keyboard 2.Main programs 3.Responsibilities 1 CS12230 Introduction to Programming Lecture 2or3-Other things.
Looking inside classes Conditional Statements Week 4.
A: A: double “4” A: “34” 4.
Lecture 33: More Graphical User Interface (GUI) Announcements & Review Read Ch GU1 & GU2 Cohoon & Davidson Ch 14 Reges & Stepp Lab 10 set game due 4/26.
1 CS1110 Thursday, 10 Feb 2011 Discussion of Methods: Executing method calls. If-statements. The return statement in a function. Local variables. For this.
Lecture 3: More on Classes Textbook: Chapter 2 Recap: –Classes vs. Objects –Q: What comes first a class or an object? –Q: Do we need a class to create.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
CS100Lecture 61 Announcements Homework P1 due on Thursday Homework P2 handed out.
Lecture 12: Dividing Up Work. Why Using Functions Divide-and-conquer making large program development more manageable. Software reusability Use existing.
CS1010 Discussion Group 11 Week 5 – Functions, Selection, Repetition.
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Based on slides by Shawn.
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
Values vs. References Lecture 13.
Michele Weigle - COMP 14 - Spr 04 Catie Welsh March 30, 2011
Yanal Alahmad Java Workshop Yanal Alahmad
Intro To Classes Review
CS305J Introduction to Computing
COMP Objects and References
Always wear gloves when working with dirty clothes.
Review Operation Bingo
Sit next to someone. Today, we do some work in pairs.
More on Classes and Objects
Exam 2 EXAM 2 Thursday!!! 25% of Final Grade
Announcements & Review
Classes Lecture 7 from Chapter /1/11.
Chapter 4 Topics: class declarations method declarations
Sit next to someone. Today, we do some work in pairs.
Classes.
Simple Classes in Java CSCI 392 Classes – Part 1.
February , 2009 CSE 113 B.
February , 2009 CSE 113 B.
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Introduction to Object-Oriented Programming
Announcements & Review
Methods/Functions.
CS 1428 Exam I Review.
Review for Midterm 3.
Announcements Lab 5 due Wednesday at noon.
Day 11 The Last Week!.
Presentation transcript:

Announcements & Review Last Time: More on input: Scanner class While loops Today more on While Methods in a class Declarations Parameters Announcements Lab 2 Due Thursday 10pm 1 file per pair Lecture 8: Simple Methods

Lecture 8: Simple Methods When do we while? boolean condition = true; // keep doing the loop while condition==true while (condition) { …. // somewhere in the loop the condition // becomes false. Why? if (test) { condition = false; } Lecture 8: Simple Methods

Reading Input Features String word1 = stdin.next(); int number1 = stdin.nextInt(); double dnum1 = stdin.nextDouble(); boolean progress1 = stdin.nextBoolean(); // peeking to make sure the format is right boolean isString = stdin.hasNext(); boolean isInt = stdin.hasNextInt(); boolean isDouble = stdin.hasNextDouble(); boolean isBoolean = stdin.hasNextBoolean(); Lecture 8: Simple Methods

Lecture 8: Simple Methods BlueJ Examples Lecture 8: Simple Methods

Why Methods? Algorithmic Thinking… Divide the program up in logical parts Analogs book with chapters; recipes; laundry Laundry Every Sunday collect dirty clothes sort into color piles (& a really dirty pile!) wash each pile dry each pile fold each pile & sort by person put them up Lecture 8: Simple Methods

Why Methods? Algorithmic Thinking… Distinct logical function organization gather, sort, wash, dry, fold, sort, put up Reuse - repetition … every week Parameterize - things that change sort differs every week number of piles, drawers, etc. Lecture 8: Simple Methods

Lecture 8: Simple Methods Reuse // public - any code can use this class // class - defines a type of object, Shapes public class Shapes { // instance variables - persistent class state // ...more on this later… /** * Constructor for objects of class Shapes */ public Shapes() { // initialize instance variables } Lecture 8: Simple Methods

Lecture 8: Simple Methods Reuse public class Shapes { // methods in this class - logical, reusable & // parameterized units // this method: its name is printBox // public - any code with a Shape object can call // printBox on object, e.g., object.printBox // private - only other Shape methods can call it // void - returns nothing public void printBox() { … } Lecture 8: Simple Methods

Lecture 8: Simple Methods BlueJ Examples Lecture 8: Simple Methods

Lecture 8: Simple Methods More Questions? Lecture 8: Simple Methods