Lecture #5 Agenda Cell phones off & name signs out Review Questions? UML class diagram introduction Our first class definition!

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Unified Modeling Language
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall NEW   NEW 1.
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
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Syntax & terminology review While the following slides are not exactly what we did on the board (object diagrams are not shown here) they cover most of.
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
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
1 Composition A whole-part relationship (e.g. Dog-Tail) Whole and part objects have same lifetime –Whole creates instance of part in its constructor In.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Where do objects come from? Objects are instances of classes We instantiate classes: –e.g.new chapter1.Terrarium() –There are three parts to this expression:
Lecture #4 Agenda Cell phones off & name signs out Review Questions? Objects The birds-and-the-bees talk.
16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
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.
Fall 2007CSE 115/503 Introduction to Computer Science for Majors I1 Announcements Attendance sheet is going around – be sure you sign it! First part of.
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
Fall 2007CSE 115/503 Introduction to Computer Science for Majors I1 End of Week Five! Questions? First part of essay assignment (choosing a topic) is posted.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
Week 3 Recap CSE 115 – Fall Java Source Code File Made up of: Package declaration Class definition.
UML class diagrams (1) UML = Unified Modeling Language We use only class diagrams, not other UML diagrams Purpose: –keep OO concepts separate from implementation.
Where do objects come from? Objects are instances of classes We instantiate classes: –e.g.new chapter1.Terrarium() –There are three parts to this expression:
Fall 2005CSE 115/503 Introduction to Computer Science I1 Composition details Recall, composition involves 3 things: –Declaration of instance variable of.
CSE 115 Week 2 January , Wednesday Announcements Pick up Syllabus if you need one Pick up Syllabus if you need one Recitation Change Form.
Object Oriented Software Development
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 01] Introduction to.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Comments are for people Header comments supply basic information about the artifact.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Java Software Solutions Lewis and Loftus Chapter 9 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Enhanced Class Design -- Introduction.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
3 Introduction to Classes and Objects.
Objects as a programming concept
Java Primer 1: Types, Classes and Operators
Chapter 3: Using Methods, Classes, and Objects
PHP Classes and Objects
Introduction to Object-oriented Program Design
Chapter 3 Introduction to Classes, Objects Methods and Strings
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Review CSE116 2/21/2019 B.Ramamurthy.
Chapter 8 Classes User-Defined Classes and ADTs
Object Oriented Programming in java
Introduction to Classes and Objects
Presentation transcript:

Lecture #5 Agenda Cell phones off & name signs out Review Questions? UML class diagram introduction Our first class definition!

Review Software development is an iterative and incremental process. OO software systems are systems of interacting objects. Objects have –properties (think of the counting object last class) –behaviors (think of the “jumping jack” object)

UML class diagrams (1) UML = Unified Modeling Language We use only class diagrams, not other UML diagrams Purpose: –keep OO concepts separate from implementation language –operate at a more abstract level than programming language, to avoid making implementation decisions when designing code

UML class diagrams (2) Class box –Class name –Properties –Behaviors Only as much detail as is needed Relationships –inheritance –implements –composition –dependency –association

UML class diagrams (3)

Where do objects come from? Objects are instances of classes We instantiate classes: –e.g.new chapter1.Terrarium() –There are three parts to this expression: new chapter1.Terrarium ()

new chapter1.Terrarium() ‘new’ is a “reserved word” in Java. This means that the word ‘new’ has a special meaning in the Java language. ‘new’ is the name of an operator whose job it is to create an instance of a given class chapter1.Terrarium is the name of the class we are instantiating. It is a compound name, consisting of a package name (chapter1) and the name of the class’ constructor (Terrarium), separated by a dot ‘.’ A constructor initializes the state of a newly created object. The parentheses delimit the argument list of the constructor call. In this case there are no arguments being passed along to the constructor, so the argument list is empty.

Packages A package is an organizational mechanism One analogy: –package::class –area code::phone number A class’ fully qualified name consists of its package name and its (unqualified) class name: –chapter1.Terrarium is a fully qualified class name –Terrarium is an unqualified class name

On to Eclipse package lecture; class EcoSystem { public EcoSystem() { }

Syntax package lecture; public class EcoSystem { public EcoSystem() { } Package declaration is shown in green:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } package is a reserved word:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } lecture is the name of the package – you choose this (we’ll cover naming rules and conventions later):

Syntax package lecture; public class EcoSystem { public EcoSystem() { } A semicolon ‘;’ marks the end of the declaration:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } The class definition is shown in green:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } The class definition consists of a header...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... and a body:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } The class header consists of an access control modifier...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... the reserved word class...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... and a class name:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } The class body begins with an opening brace ‘{’...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... and ends with the matching closing brace ‘}’ :

Syntax package lecture; public class EcoSystem { public EcoSystem() { } In this example, the body consists of a single constructor definition:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } The constructor definitons consists of a header...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... and a body:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } The constructor header consists of an access control modifier...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... the constructor name (which is the same as the class name)...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... and a parameter list:

Syntax package lecture; public class EcoSystem { public EcoSystem() { } The constructor body begins with an opening brace ‘{’...

Syntax package lecture; public class EcoSystem { public EcoSystem() { }... and ends with the matching closing brace ‘}’ :