Class 18 - Click to edit Master subtitle style 12/4/09...

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: Click to edit Master subtitle style 12/4/09 Methods in Java Matthew Hashim 10/27/2009 11 MGMT 290D 12/4/09 Goals for Today n Build your own Java methods n Define parameters and pass arguments to them n Build a method library 22 MGMT 290D MGMT 290D 12/4/09 Methods n How to perform a method Send a message to an object or class n Building a method in Alice Click the create new method button Drag statements into the method n Focus of Chapter 9 Learning how to build methods in Java 3 MGMT 290D MGMT 290D 12/4/09 Introductory Example: The Hokey Pokey Song n Problem: write a Java program to display song lyrics 4 MGMT 290D MGMT 290D 12/4/09 Introductory Example: The Hokey Pokey Song (continued) 5 MGMT 290D 12/4/09 Introductory Example: The Hokey Pokey Song (continued) n Brute force approach One String object stores the song lyrics One action displays those lyrics Implement program using one println() message Issue: program is about 60 lines long (excessive) 6 MGMT 290D MGMT 290D 12/4/09 Introductory Example: The Hokey Pokey Song (continued) n A better approach takes advantage of song structure Each verse only differs by the body part that is moved Implement program with a single method to print verse printVerse() takes one argument for the bodyPart 7 MGMT 290D MGMT 290D 12/4/09 Introductory Example: The Hokey Pokey Song (continued) 8 MGMT 290D MGMT 290D 12/4/09 Introductory Example: The Hokey Pokey Song (continued) 9 MGMT 290D MGMT 290D 12/4/09 Methods (continued) n Analyzing the first line of printVerse() public : allows another class access to the method static : indicates that the message is a class method void : indicates that the method does not return a value...
View Full Document

Page1 / 27

Class 18 - Click to edit Master subtitle style 12/4/09...

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