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.

Slides:



Advertisements
Similar presentations
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
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
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Agenda –interfaces and realization –type hierarchy –introduction to graphics and event handling.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Fall 2007CSE 115/503 Introduction to Computer Science for Majors I1 Association relationship We’ve seen one implementation of “knows a”: public class Dog.
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 Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE 115/503 Introduction to Computer Science for Majors I1 Example Dog fido = new Dog(new Collar()); Dog rover = new Dog(new Collar()); rover.setCollar(fido.getCollar());
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
Fall 2007CSE 115/503 Introduction to Computer Science for Majors I1 Now What? What if we want to talk to something that was created somewhere else? E.g.
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.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Fall 2005CSE 115/503 Introduction to Computer Science I1 Reminder Check the course web site on a regular basis:
CSE 115 / 503 Introduction to Computer Science For Majors I Carl Alphonce 219 Bell Hall.
Week 4 Recap CSE 115 Spring Formal Parameter Lists Comma-separated list of formal parameters Formal parameters are listed giving the type of the.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Object Classes In UML. Object Concepts What is an object? How do objects communicate? How is an object’s interface defined? What have objects to do with.
CS 106 Introduction to Computer Science I 03 / 21 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Fall 2005CSE 115/503 Introduction to Computer Science I1 Association Also called “knows a”. A relationship of knowing (e.g. Dog-Collar as opposed to Dog-Tail)
CSE 115 / 503 Introduction to Computer Science For Majors I Carl Alphonce 219 Bell Hall.
CSE 115 Week 4 February 4 - 8, Monday Announcements Software installation fest Tuesday & Wednesday 4-7 in Baldy 21. Software installation fest Tuesday.
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.
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.
Abstract Data Types and Encapsulation Concepts
CSE 116 Introduction to Computer Science For Majors II Carl Alphonce 219 Bell Hall.
CSE 115 / 503 Introduction to Computer Science I
Fall 2005CSE 115/503 Introduction to Computer Science I1 Composition details Recall, composition involves 3 things: –Declaration of instance variable of.
More C++ Bryce Boe 2013/07/18 CS24, Summer 2013 C.
ACO 101: Introduction to Computer Science Anatomy Part 2: Methods.
CET203 SOFTWARE DEVELOPMENT Session 1A Revision of Classes.
1 3/2/05CS250 Introduction to Computer Science II Composition and friend Functions.
Thanks, Andrew. Reminders: –wear the wireless mike –combination is 1-31 –speak slowly, pause for questions –I’d rather you get through less material than.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
Chapter 11 An introduction to object-oriented design.
Review for Test2. Scope 8 problems, 60 points. 1 Bonus problem (5 points) Coverage: – Test 1 coverage – Exception Handling, Switch Statement – Array of.
Objects as a programming concept
CS148 Introduction to Programming II
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Which best describes the relationship between classes and objects?
February , 2009 CSE 113 B.
Announcements Lab 5 was due today Program 3 due Monday by 12pm
CMSC202 Computer Science II for Majors Lecture 10 and 11 – Inheritance
Unit-2 Objects and Classes
Classes and Objects Object Creation
Presentation transcript:

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 essay assignment (choosing a topic) is posted on the website. Check it out!

Fall 2007CSE 115/503 Introduction to Computer Science for Majors I2 Association relationship We’ve seen one implementation of “knows a”: public class Dog { private Collar _collar; public Dog(Collar collar) { _collar = collar; } Now we will see a more flexible implementation.

Fall 2007CSE 115/503 Introduction to Computer Science for Majors I3 Essence of association We use an association relationship when we want to model that one object can communicate with another object (as in the composition relationship) but –there isn’t any lifetime link between the two objects, or –the objects in the relationship can change over time (think of Clifford’s collar).

Fall 2007CSE 115/503 Introduction to Computer Science for Majors I4 Changing the known property We want to be able to set a new value for the property (e.g. give Clifford a new collar). How can we do that? Using a “mutator” or “setter” method.

Fall 2007CSE 115/503 Introduction to Computer Science for Majors I5 mutator method public class Dog{ private Collar _collar; public Dog(Collar collar){ _collar = collar; } public void setCollar(Collar collar){ _collar = collar; }

Fall 2007CSE 115/503 Introduction to Computer Science for Majors I6 Constructor/mutator similarity Note the similarity between the constructor and the mutator. With respect to the _collar variable, they are doing essentially the same thing: allowing the invoker to set the value of the instance variable. Difference is that constructor sets value when Dog object is created, mutator changes the value at some later point in time.