20091007-Methods

20091007-Methods - CSE115: Introduction to Computer Science...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 alphonce@buffalo.edu 1 Agenda non-void method accessor method method with parameters mutator method method calls in detail association relationship Accessor method A method which returns information, the value of an objects property. These methods typically have names that start with get. 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; } } Mutator methods A method which accepts information and sets the value of an objects property. So-called because method changes (mutates) the value of a property. Mutator methods typically have names that start with set. Mutator example public class EcoSystem { private example1.Terrarium _t; public EcoSystem() { _t = new example1.Terrarium(); } public void setTerrarium(example1.Terrarium t){ _t = t; } } Blackboard example EcoSystem es = new EcoSystem(); es EcoSystem _t Terrarium Terrarium Blackboard example EcoSystem es = new EcoSystem(); example1.Terrarium terra = new example1.Terrarium(); es EcoSystem _t Terrarium terra Terrarium Blackboard example EcoSystem es = new EcoSystem(); example1.Terrarium terra = new example1.Terrarium(); es.setTerrarium(terra); es EcoSystem _t Terrarium terra Blackboard example...
View Full 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: Introduction to Computer Science...

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