20091007-Methods

20091007-Methods - CSE115:Introductionto ComputerScienceI...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style CSE115: Introduction to  Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 alphonce@buffalo.edu 11
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Phones off Signs out
Background image of page 2
Agenda non-void method accessor method method with parameters mutator method method calls in detail association relationship
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Accessor method A method which returns information, the  value of an object’s property. These methods typically have names that  start with “get”.
Background image of page 4
Accessor  example simple example of a method that returns  a value public class EcoSystem { private example1.Terrarium _t; public EcoSystem() { _t = new example1.Terrarium(); } public example1.Terrarium getTerrarium() { return _t; } }
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Mutator methods A method which accepts information and  sets the value of an object’s property. So-called because method changes  (mutates) the value of a property. Mutator methods typically have names  that start with “set”.
Background image of page 6
Mutator example public class EcoSystem { private example1.Terrarium _t; public EcoSystem() { _t = new example1.Terrarium(); } public void setTerrarium(example1.Terrarium t){ _t = t; } }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Blackboard example EcoSystem es = new EcoSystem(); es EcoSystem _t Terrarium
Background image of page 8
Terrarium Blackboard example EcoSystem es = new EcoSystem(); example1.Terrarium terra = new example1.Terrarium(); es EcoSystem _t Terrarium terra
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Terrarium Blackboard example
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/13/2011 for the course CSE 115 taught by Professor Decker during the Fall '08 term at SUNY Buffalo.

Page1 / 26

20091007-Methods - CSE115:Introductionto ComputerScienceI...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online