CSE 115 September 29 – October 3, 2008.

Slides:



Advertisements
Similar presentations
Parameter passing mechanism: pass-by-reference. The Pass-by-reference mechanism - the agreement Recall: Parameter passing mechanism = agreement between.
Advertisements

Spring Semester 2013 Lecture 5
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Defining classes and methods Recitation – 09/(25,26)/2008 CS 180 Department of Computer Science, Purdue University.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE 115 Week 11 March , Announcements March 26 – Exam 7 March 26 – Exam 7 March 28 – Resign Deadline March 28 – Resign Deadline Lab 7 turned.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
CSE 115 Week 5 February , Monday Announcements Exam 3 today Exam 3 today Lab 3 due this week Lab 3 due this week Exam 4 Monday 2/18 Exam.
CSE 115 Week 10 March , Announcements March 21 – Lab 7 Q & A in lecture March 21 – Lab 7 Q & A in lecture March 26 – Exam 7 March 26 – Exam.
Week 4 Recap CSE 115 Spring Formal Parameter Lists Comma-separated list of formal parameters Formal parameters are listed giving the type of the.
CSE 113 Week 3 January 28 – February 1, Monday Announcements  Software Installation Fest: 2/5 and 2/6 4pm – 7pm in Baldy 21 Bring your laptop or.
Week 2 Recap CSE 115 – Spring Object Oriented Program System of objects that communicate with one another to solve some problem.
COMP 110 Introduction to Programming Mr. Joshua Stough October 8, 2007.
Understanding class definitions Looking inside classes 3.0.
Week 4 Recap CSE 115 Fall 2006 Section C. Decoupling Separation of concerns Defining what an object can do, not how it does it.
Week 5 Recap CSE 115 Spring Composition Informally called “has a” Represented in UML with a diamond- headed arc In code: Declare an instance variable.
CSE 115 Week 3 January 28 – February 1, Monday Announcements Software Installation Fest: 2/5 and 2/6 4pm – 7pm in Baldy 21 Software Installation.
CSE 115 Week 4 February 4 - 8, Monday Announcements Software installation fest Tuesday & Wednesday 4-7 in Baldy 21. Software installation fest Tuesday.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
Parameters, Arguments, Local Variables, and Scope CSC 1401: Introduction to Programming with Java Week 8 – Lecture 1 Wanda M. Kunkle.
Week 3 Recap CSE 115 – Fall Java Source Code File Made up of: Package declaration Class definition.
CSE 115 Week 2 January , Wednesday Announcements Pick up Syllabus if you need one Pick up Syllabus if you need one Recitation Change Form.
Introduction to Methods
Chapter 6: Function. Scope of Variable A scope is a region of the program and broadly speaking there are three places, where variables can be declared:
Java Methods By J. W. Rider. Java Methods Modularity Declaring methods –Header, signature, prototype Static Void Local variables –this Return Reentrancy.
COMP More About Classes Yi Hong May 22, 2015.
Chapter 4 Procedural Methods. Learning Java through Alice © Daly and Wrigley Objectives Identify classes, objects, and methods. Identify the difference.
Introduction to programming in the Java programming language.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 7 Clicker Questions September 22, 2009.
Documentation and Programming Style Appendix A © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Introduction to Methods. Previously discussed There are similarities in make up of that can help you remember the construct of a class a class in the.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
User Defined Methods Methods are used to divide complicated programs into manageable pieces. There are predefined methods (methods that are already provided.
An Introduction to Programming with C++ Sixth Edition Chapter 10 Void Functions.
CMSC 150 METHODS AND CLASSES CS 150: Wed 25 Jan 2012.
01/24/2005 Introduction to Programming with Java, for Beginners A Closer Look at Constructors and Methods.
Lecture 4.1 More About Methods - Using a Prototyping Approach.
Invoking methods in the Java library. Jargon: method invocation Terminology: Invoking a method = executing a method Other phrases with exactly the same.
Functions Skill Area 314 Part B. Lecture Overview Functions Function Prototypes Function Definitions Local Variables Global Variables Default Parameters.
Announcements. Practice questions, with and without solutions will be uploaded by Friday 5 th November, make sure to check them before the weekend \\netstorage\Subjects\ITCA-b\Exam.
Prototyping with Methods
Chapter 10: Void Functions
Prototyping with Methods
CISC/CMPE320 - Prof. McLeod
Chapter 4 Procedural Methods.
Chapter 4 void Functions
CSE 115 September 29 – October 3, 2008.
CSE 113 A January 26 – 30, 2009.
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Learning Objectives Classes Constructors Principles of OOP
Chapter 7 Procedural Methods.
January 26 – 30, 2009 CSE 113 B.
CSE 115 November , 2008.
Notes from Week 5 CSE 115 Spring 2006 February 13, 15 & 17, 2006.
CSE 115 October , 2008.
CSE 115 September 12, 2008.
February , 2009 CSE 113 B.
February 2 - 6, 2009 CSE 113 B.
CSE 115 October , 2008.
ENERGY 211 / CME 211 Lecture 8 October 8, 2008.
CISC101 Reminders Assignment 3 due today.
SPL – PS3 C++ Classes.
C Parameter Passing.
Programming Techniques
Presentation transcript:

CSE 115 September 29 – October 3, 2008

Announcements Lab 5 posted Note schedule of labs for the next two weeks No classes meet Tuesday Lab 5 due the day before your lab meets during the week of October 13th Exam 3 is October 17th Check UBLearns for grades on Exam 1 and Labs 1 & 2.

Lesson Plan Building graphical programs Writing methods

Methods Realization in Java code of the capabilities of an object Methods are made up of a method header and a method body Method header: public returnType methodName (parameter list)

Method Header Details public – accessible from all parts of program returnType – type of information returned from the method; void is return type if nothing is returned methodName – identifier; style is first letter lower case and first letters of subsequent words upper case parameter list – possibly empty list of information needed for the method to complete its tasks

Parameters If a parameter is needed, inside the () you see: type parameterName Where type is the type of the parameter and parameterName is an identiifier we will use to refer to the parameter inside the method body. Style is the same as method names and local variables. In fact, you could consider a parameter as a special type of local variable. It is assigned its initial value during the method call and its scope is only within the method body.

Method body Enclosed inside { } Contains the code that performs the actions of the method.

Important Note In order for methods to execute (the code inside the body to actually run), we need to make sure that they are called. Recall calling methods: objectReference.methodName(); We need to insert an argument (value) into the () if the method requires one.

Keyword this The keyword this is a self-reference and is used from within the class to refer to itself. It is a reference, similar to the references we create and name ourselves, except it refers to the object that will be created when the class is created. Another way to think of it is to replace the word this with self inside the code.