chapter 8 slides

58

Upload: kaleb

Post on 04-Jan-2016

66 views

Category:

Documents


1 download

DESCRIPTION

Exposure Java 2011 APCS Edition. Chapter 8 Slides. Creating Object Methods. PowerPoint Presentation created by: Mr. John L. M. Schram and Mr. Leon Schram authors of Exposure Java. Section 8.1. Introduction. Objects, Variables & Methods. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 8 Slides
Page 2: Chapter 8 Slides
Page 3: Chapter 8 Slides

Objects, Variables & Methods

Java encapsulates data and action modules that access the data in one container, called an object.

Object members that perform some task are called methods.

Object members that store data are called attributes.

Page 4: Chapter 8 Slides

Important Note:

Expect to read this material a number of times.

Many concepts will be new and foreign to you.

Even small, well-presented program examples, do not always make sense during the very first introduction of a new topic.

Page 5: Chapter 8 Slides
Page 6: Chapter 8 Slides

Normal “Non-OOP” Airport

In a normal airport, the following places are scattered all over the airport.

• Curb-Side Check-In• Security• Departure Gates• Arrival Gates• Baggage claim

The same gates are used for the arrival and departure of different planes to different places.

Page 7: Chapter 8 Slides

“OOP-ified” AirportAn airport would never be designed this way, but if they followed the encapsulation concept of OOP, you would have the following Destination objects:

class Destination object Paris

Methods:Check-InSecurityGates

class Destination object Amsterdam

Methods:Check-InSecurityGates

Page 8: Chapter 8 Slides
Page 9: Chapter 8 Slides
Page 10: Chapter 8 Slides

// Java0801.java// This program introduces the Piggy class, which will be used// to demonstrate a variety of Object Oriented Programming features.// This program uses static class variables and static class methods.// Every Piggy method is accessed using the Piggy class identifier.

public class Java0801{

public static void main(String args[]){

System.out.println("\nJAVA0801.JAVA\n");Piggy.initData();Piggy.showData();Piggy.addData(1200);Piggy.showData();System.out.println();

} }

class Piggy{

static double savings;public static void initData() { savings = 0; }public static void addData(double s) { savings += s; }public static void showData() { System.out.println("Savings: " + savings); }

}

Page 11: Chapter 8 Slides

// Java0802.java// This program removes the static keyword from the members of the// Piggy class. The program no longer compiles.

public class Java0801{

public static void main(String args[]){

System.out.println("\nJAVA0802.JAVA\n");Piggy.initData();Piggy.showData();Piggy.addData(1200);Piggy.showData();System.out.println();

} }

class Piggy{

static double savings;public void initData() { savings = 0; }public void addData(double s) { savings += s; }public void showData() { System.out.println("Savings: " + savings); }

}

Page 12: Chapter 8 Slides

// Java0803.java// In this program a tom object of the Piggy class is instantiated.// The program compiles now because the methods of the Piggy// class are treated like "object" methods.

public class Java0803{

public static void main(String args[]){

System.out.println("\nJAVA0803.JAVA\n");Piggy tom = new Piggy();tom.initData();tom.showData();tom.addData(1200);tom.showData();System.out.println();

} }

class Piggy{

double savings;public void initData() { savings = 0; }public void addData(double s) { savings += s; }public void showData() { System.out.println("Savings: " + savings); }

}

Page 13: Chapter 8 Slides

// Java0804.java// This program constructs multiple objects of the Piggy class.// Using objects allows storing information in multiple instances// of the Piggy class. This is not possible with static methods.public class Java0804{

public static void main(String args[]){

System.out.println("\nJAVA0804.JAVA\n");Piggy tom = new Piggy();tom.initData();tom.addData(1200);tom.showData();Piggy sue = new Piggy();sue.initData();sue.addData(2500);sue.showData();System.out.println();

} }class Piggy{

double savings;public void initData() { savings = 0; }public void addData(double s) { savings += s; }public void showData() { System.out.println("Savings: " + savings); }

}

Page 14: Chapter 8 Slides
Page 15: Chapter 8 Slides

// Java0805.java// This program exchanges the initData method with the Piggy constructor.// Constructors add reliability to programs because they are called// automatically during the instantiation of a new object.public class Java0805{

public static void main(String args[]){

System.out.println("\nJAVA0805.JAVA\n");Piggy tom = new Piggy();tom.showData();tom.addData(1200);tom.showData();System.out.println();

} }class Piggy{

double savings;public Piggy(){

System.out.println("Constructing a Piggy object");savings = 0;

}public void addData(double s) { savings += s; }public void showData() { System.out.println("Savings: " + savings); }

}

Page 16: Chapter 8 Slides

Instantiation & Construction

A class is a template that can form many objects.

An object is a single variable instance of a class.

Objects are sometimes called instances.

An object is created with the new operator.

The creation of a new object is called:instantiation of an objectconstruction of an object

The special method that is called during the instantiation of an object is called a constructor.

Page 17: Chapter 8 Slides

// Java0806.java// This program demonstrates that constructors can be overloaded. It is possible to supply// information, using parameters, to the new object at the instance that it is constructed.

public class Java0806 {public static void main(String args[]) {

System.out.println("\nJAVA0806.JAVA\n");Piggy tom = new Piggy();tom.showData();Piggy sue = new Piggy("Sue",1800);sue.showData(); System.out.println();

} }class Piggy {

double savings; String name;public Piggy() {

System.out.println("No parameter constructor");savings = 0;name = "";

}public Piggy(String n,double s) {

System.out.println("Parameter constructor");name = n;savings = s;

}public void showData() {

System.out.println("Name: " + name);System.out.println("Savings: " + savings);

}}

Page 18: Chapter 8 Slides

Constructor NotesConstructors are methods, which are called during the instantiation of an object with the new operator.

The primary purpose of a constructor is to initialize all the attributes of newly created object.

Constructors have the same identifier as the class.

Constructors are neither void methods nor return methods.

Constructors can be overloaded methods.

The method identifier can be the same, but the method signature must be different.

Page 19: Chapter 8 Slides
Page 20: Chapter 8 Slides

// Java0807.java// In this program "main" accesses the variables of the tom object.// Object variables should only be accessed by member object methods.

public class Java0807

{

public static void main(String args[])

{

System.out.println(“

\nJAVA0807.JAVA\n");

Piggy tom = new Piggy("Tom",2000);

tom.showData();

tom.name = "George";tom.savings = 2500000;tom.showData();

System.out.println();

}

}

class Piggy{

double savings;String name;public Piggy(){

System.out.println("No parameter constructor");savings = 0;name = "";

}public Piggy(String n,double s){

System.out.println("Parameter constructor");name = n;savings = s;

}public void showData(){

System.out.println("Name: " + name);System.out.println("Savings: " + savings);

}}

Both of these classes are in the same file.

They could also be put in 2 separate files:

Java0807.java and Piggy.java

Page 21: Chapter 8 Slides

// Java0808.java// Java keyword "private" is placed in front of the Piggy variables.// Piggy variables are no longer accessible from outside the Piggy class.// This program will not compile.

public class Java0808

{

public static void main(String args[])

{

System.out.println(“

\nJAVA0808.JAVA\n");

Piggy tom = new Piggy("Tom",2000);

tom.showData();

tom.name = "George";tom.savings = 2500000;tom.showData();

System.out.println();

}

}

class Piggy{

private double savings;private String name;public Piggy(){

System.out.println("No parameter constructor");savings = 0;name = "";

}public Piggy(String n,double s){

System.out.println("Parameter constructor");name = n;savings = s;

}public void showData(){

System.out.println("Name: " + name);System.out.println("Savings: " + savings);

}}

Both of these classes are in the same file.

They could also be put in 2 separate files:

Java0808.java and Piggy.java

Page 22: Chapter 8 Slides

private & public MembersMembers in a class need to be declared as private or public.

private members cannot be accessed by any program segments outside the class.

Data attributes of a class usually need to be declared private.

public members of a class can be accessed by program segments outside the class.

Page 23: Chapter 8 Slides

// Java0809.java// This program accesses the object variables only with methods of the same object.// The program is divided into private and public members.

public class Java0809

{

public static void main(String args[])

{

System.out.println(

"\nJAVA0809.JAVA\n");

Piggy tom = new Piggy(

"Tom",2000);

System.out.println(

"Name: " + tom.getName());

System.out.println(

"Savings: " + tom.getSavings());

System.out.println();

}

}

class Piggy

{

private double savings;

private String name;

public Piggy()

{

System.out.println("No parameter constructor");

savings = 0;

name = "";

}

public Piggy(String n,double s)

{

System.out.println("Parameter constructor");

name = n;

savings = s;

}

public double getSavings() { return savings; }

public String getName() { return name; }

}

Page 24: Chapter 8 Slides
Page 25: Chapter 8 Slides

The CardDeck Case StudyCardDeck Methods CardDeck Data

Initialize Deck # of Decks

Shuffle Deck # of Players

Deal Cards From Deck # of Cards Dealt

Count Leftover Cards # of Cards Left

Page 26: Chapter 8 Slides

// Java0810.java// CardDeck Case Study #01// This shows the minimum CardDeck declaration. This program// does not use the CardDeck object yet, but it will compile.

public class Java0810{

public static void main(String args[]){

System.out.println("\nCard Deck Case Study 01\n");CardDeck d = new CardDeck();System.out.println();

}}

class CardDeck{}

Page 27: Chapter 8 Slides

// Java0811.java// CardDeck Case Study #02// Variables are added to the CardDeck class

public class Java0811{

public static void main(String args[]){

System.out.println("\nCard Deck Case Study 02\n");System.out.println();CardDeck d = new CardDeck();System.out.println();

}}

class CardDeck{

int numDecks; // number of decks in a gameint numPlayers; // number of players in a gameint cardsLeft; // number of cards left in the deck(s)

}

Page 28: Chapter 8 Slides

// Java0812.java// CardDeck Case Study #03// CardDeck variables are accessed directly by the "main" method outside the CardDeck// class. The program compiles, and executes. This approach greatly compromises // program reliability and demonstrates very poor OOP program design.

public class Java0812{

public static void main(String args[]){

System.out.println("\nCard Deck Case Study 03\n");CardDeck d = new CardDeck();d.numDecks = 4;d.numPlayers = 5;d.cardsLeft = 208;System.out.println(d.numDecks + " card deck(s)"); System.out.println(d.numPlayers + " players");System.out.println(d.cardsLeft + " cards left");System.out.println();

}}

class CardDeck{

int numDecks; // number of decks in a gameint numPlayers; // number of players in a gameint cardsLeft; // number of cards left in the deck(s)

}

Page 29: Chapter 8 Slides

// Java0813.java// CardDeck Case Study #04// All the variables in the CardDeck class are declared as "private".// This prevents outside access to the variables. The program will no // longer compile because "main" attempts to access private data.

public class Java0813{

public static void main(String args[]){

System.out.println("\nCard Deck Case Study 04\n");CardDeck d = new CardDeck();d.numDecks = 4;d.numPlayers = 5;d.cardsLeft = 208;System.out.println(d.numDecks + " card deck(s)"); System.out.println(d.numPlayers + " players");System.out.println(d.cardsLeft + " cards left");System.out.println();

}}

class CardDeck{

private int numDecks; // number of decks in a gameprivate int numPlayers; // number of players in a gameprivate int cardsLeft; // number of cards left in the deck(s)

}

Page 30: Chapter 8 Slides

// Java0814.java// CardDeck Case Study #05// The CardDeck class now has a constructor to initialize variables// during the instantiation of a new CardDeck object.

public class Java0814{

public static void main(String args[]){

System.out.println("\nCard Deck Case Study 05\n");CardDeck d = new CardDeck();System.out.println();

}}

class CardDeck{

private int numDecks; // number of decks in a gameprivate int numPlayers; // number of players in a gameprivate int cardsLeft; // number of cards left in the deck(s)public CardDeck(){

numDecks = 1;numPlayers = 1;cardsLeft = 52;

}}

Page 31: Chapter 8 Slides

// Java0815.java// CardDeck Case Study #06// The CardDeck class now has three accessing methods to return // variable values of CardDeck objects.

public class Java0815{

public static void main(String args[]){

System.out.println("\nCard Deck Case Study 06\n");CardDeck d = new CardDeck();System.out.println(d.getDecks() + " card deck(s)"); System.out.println(d.getPlayers() + " players");System.out.println(d.getCards() + " cards left");System.out.println();

}}

class CardDeck{

private int numDecks; // number of decks in a gameprivate int numPlayers; // number of players in a gameprivate int cardsLeft; // number of cards left in the deck(s)public CardDeck(){

numDecks = 1; numPlayers = 1; cardsLeft = 52;}public int getDecks() { return numDecks; }public int getPlayers() { return numPlayers; }public int getCards() { return cardsLeft; }

}

Page 32: Chapter 8 Slides

// Java0816.java// CardDeck Case Study #07// This program adds the shuffleCards method, which is a private method used by the CardDeck// constructor. This is an example of increasing reliability by the automatic constructor call.class Java0816{

public static void main(String args[]){

System.out.println("\nCard Deck Case Study 07\n");CardDeck d = new CardDeck();System.out.println(d.getDecks() + " card deck(s)"); System.out.println(d.getPlayers() + " players");System.out.println(d.getCards() + " cards left"); System.out.println();

}}class CardDeck{

private int numDecks; // number of decks in a gameprivate int numPlayers; // number of players in a gameprivate int cardsLeft; // number of cards left in the deck(s)private void shuffleCards() { System.out.println("Shuffling Cards"); }public CardDeck(){

numDecks = 1; numPlayers = 1; cardsLeft = 52;shuffleCards();

}public int getDecks() { return numDecks; }public int getPlayers() { return numPlayers; }public int getCards() { return cardsLeft; }

}

Page 33: Chapter 8 Slides

// Java0817.java // CardDeck Case Study #08// This program adds a second, overloaded constructor. It is now possible // to instantiate a new CardDeck object with specified data values.public class Java0817{ public static void main(String args[]) { System.out.println("\nCard Deck Case Study 07\n"); CardDeck d1 = new CardDeck();

System.out.println(d1.getDecks() + " card deck(s)"); System.out.println(d1.getPlayers() + " players"); System.out.println(d1.getCards() + " cards left"); System.out.println(); CardDeck d2 = new CardDeck(4,5); System.out.println(d2.getDecks() + " card deck(s)"); System.out.println(d2.getPlayers() + " players"); System.out.println(d2.getCards() + " cards left"); System.out.println(); }}

Page 34: Chapter 8 Slides

class CardDeck{ private int numDecks; // number of decks in a game private int numPlayers; // number of players in a game private int cardsLeft; // number of cards left in the deck(s) private void shuffleCards() { System.out.println("Shuffle Cards"); } public CardDeck() { System.out.println("Constructing a default CardDeck object"); numDecks = 1; numPlayers = 1; cardsLeft = 52; shuffleCards(); } public CardDeck(int d, int p) { System.out.println("Constructing a CardDeck object with parameters"); numDecks = d; numPlayers = p; cardsLeft = d * 52; shuffleCards(); } public int getDecks() { return numDecks; } public int getPlayers() { return numPlayers; } public int getCards() { return cardsLeft; }}

Page 35: Chapter 8 Slides
Page 36: Chapter 8 Slides
Page 37: Chapter 8 Slides

// Java0818.java// This tests the <Bank> class, which was originally used in Chapter III.// This time the source code of Bank.java is shown.public class Java0818{

public static void main (String args[]){

System.out.println("\nJAVA0818.JAVA\n");Bank tom = new Bank(5000.0,10000.0);Bank sue = new Bank(3000.0,15000.0);

System.out.println("Tom's checking balance: " + tom.getChecking());System.out.println("Tom's savings balance: " + tom.getSavings());System.out.println("Sue's checking balance: " + sue.getChecking());System.out.println("Sue's savings balance: " + sue.getSavings());System.out.println();System.out.println("Tom makes a $1000.00 checking withdrawal");tom.changeChecking(-1000.0);System.out.println("Tom makes a $2000.00 savings withdrawal");tom.changeSavings(-2000.0);System.out.println("Sue makes a $1500.00 checking deposit");sue.changeChecking(+1500.0);System.out.println("Sue makes a $3000.00 savings deposit");sue.changeSavings(+3000.0);System.out.println();System.out.println("Tom's combined balance: " + tom.getCombined());System.out.println("Sue's combined balance: " + sue.getCombined()); System.out.println();tom.closeChecking(); tom.closeSavings();sue.closeChecking(); sue.closeSavings();System.out.println("Tom's combined balance: " + tom.getCombined());System.out.println("Sue's combined balance: " + sue.getCombined()); System.out.println();

}}

Page 38: Chapter 8 Slides
Page 39: Chapter 8 Slides

// Bank.java

// This file contains the <Bank> class used to demonstrate using object methods

// for an earlier chapter.

public class Bank

{

private double checking;

private double savings;

public Bank() { checking = 0.0; savings = 0.0; }

public Bank(double c, double s) { checking = c; savings = s; }

public double getChecking() { return checking; }

public double getSavings() { return savings; }

public double getCombined() { return checking + savings; }

public void changeChecking(double amount) { checking += amount; }

public void changeSavings(double amount) { savings += amount; }

public void closeChecking() { checking = 0; }

public void closeSavings() { savings = 0; }

}

Page 40: Chapter 8 Slides
Page 41: Chapter 8 Slides

The Cube Case StudyCube Methods Cube Data

Draw Cube x Coordinate

Erase Cube y Coordinate

Move Cube size

Page 42: Chapter 8 Slides

// Java0819.java Cube Casestudy #1// Stage #1 presents a <Cube> class with a constructor to initialize instance variables.

import java.awt.*;import java.applet.*;

public class Java0819 extends Applet{

public void paint(Graphics g){

Cube cube = new Cube(g);}

}

class Cube{

private int tlX; // topleft X coordinate of the Cube's positionprivate int tlY; // topleft y coordinate of the Cube's position

public Cube(Graphics g){

tlX = 50;tlY = 50;

}}

Page 43: Chapter 8 Slides

// Java0820.java Cube Casestudy #2// Stage #2 presents adds a <draw> method to display one cube object.public class Java0820 extends Applet{

public void paint(Graphics g){

Cube cube = new Cube(g);cube.draw(g);

}}class Cube{

private int tlX; // topleft X coordinate of the Cube's positionprivate int tlY; // topleft y coordinate of the Cube's position

public Cube(Graphics g) { tlX = 50; tlY = 50; }

public void draw(Graphics g){

int tlX2 = tlX + 12;int tlY2 = tlY + 12;g.setColor(Color.black);g.drawRect(tlX,tlY,50,50);g.drawRect(tlX2,tlY2,50,50);g.drawLine(tlX,tlY,tlX2,tlY2);g.drawLine(tlX+50,tlY,tlX2+50,tlY2);g.drawLine(tlX,tlY+50,tlX2,tlY2+50);g.drawLine(tlX+50,tlY+50,tlX2+50,tlY2+50);

}}

Page 44: Chapter 8 Slides

// Java0821.java Cube Casestudy #3// Stage #3 adds a second, overloaded constructor. // It is now possible to specify the size and the location of the cube. // The <draw> method needs to be altered to handle different cube sizes.

import java.awt.*;import java.applet.*;

public class Java0821 extends Applet{

public void paint(Graphics g){

Cube cube1 = new Cube(g,50,50,50);cube1.draw(g);Cube cube2 = new Cube(g,400,50,100);cube2.draw(g);Cube cube3 = new Cube(g,50,300,150);cube3.draw(g);Cube cube4 = new Cube(g,400,300,200);cube4.draw(g);

}}

class Cube{

private int tlX;private int tlY;private int size;public Cube(Graphics g){

tlX = 50; tlY = 50; size = 50;}public Cube(Graphics g, int x, int y, int s){

tlX = x; tlY = y; size = s;}public void draw(Graphics g){

int tlX2 = tlX + size/3;int tlY2 = tlY + size/3;g.setColor(Color.black);g.drawRect(tlX,tlY,size,size);g.drawRect(tlX2,tlY2,size,size);g.drawLine(tlX,tlY,tlX2,tlY2);g.drawLine(tlX+size,tlY,tlX2+size,tlY2);g.drawLine(tlX,tlY+size,tlX2,tlY2+size);g.drawLine(tlX+size,tlY+size,tlX2+size,tlY2+size);

}}

Page 45: Chapter 8 Slides
Page 46: Chapter 8 Slides

// Java0822.java Cube Casestudy #4// Stage #4 adds a <move> method, which updates the cube's coordinates// and draws a cube at the new location.// Only new methods are shown.

public class Java0822 extends Applet{

public void paint(Graphics g){

Cube cube = new Cube(g,50,50,50);for (int x = 50; x < 750; x += 50)

cube.move(g,x,300);}

}

class Cube{

private int tlX; // topleft X coordinate of the Cube's positionprivate int tlY; // topleft y coordinate of the Cube's positionprivate int size; // the size of the cube along one edge

public void move(Graphics g, int x, int y){

tlX = x; tlY = y; draw(g);}

}

Page 47: Chapter 8 Slides

// Java0823.java Cube Casestudy #5

// Stage #5 adds an <erase> method, which erases the cube at the current [tlX,tlY] coordinates.

// This program has a problem because the cube object is erased immediately after it is drawn.

import java.awt.*;import java.applet.*;

public class Java0823 extends Applet

{

public void paint(Graphics g)

{

Cube cube = new Cube(g,50,50,50);

for (int x = 50; x < 750; x += 50)

{

cube.move(g,x,300);

cube.erase(g);}

}

}

class Cube

{

private int tlX; // topleft X coordinate of the Cube's position

private int tlY; // topleft y coordinate of the Cube's position

private int size; // the size of the cube along one edge

public void erase(Graphics g)

{

int tlX2 = tlX + size/3;

int tlY2 = tlY + size/3;

g.setColor(Color.white);

g.drawRect(tlX,tlY,size,size);

g.drawRect(tlX2,tlY2,size,size);

g.drawLine(tlX,tlY,tlX2,tlY2);

g.drawLine(tlX+size,tlY,tlX2+size,tlY2);

g.drawLine(tlX,tlY+size,tlX2,tlY2+size);

g.drawLine(tlX+size,tlY+size,tlX2+size,tlY2+size);

}

}

Page 48: Chapter 8 Slides
Page 49: Chapter 8 Slides

// Java0824.java Cube Casestudy #6

// Stage #6 adds a <delay> method which stops program execution for a specified number of

// milli seconds. This makes the cube visible and creates a simple type of animation.

import java.awt.*;import java.applet.*;

public class Java0824 extends Applet

{

public void paint(Graphics g)

{

Cube cube = new Cube(g,50,50,50);

for (int x = 50; x < 750; x += 50)

{

cube.move(g,x,300);

cube.delay(100);cube.erase(g);

}

}

}

class Cube

{

private int tlX; // topleft X coordinate of the Cube's position

private int tlY; // topleft y coordinate of the Cube's position

private int size; // the size of the cube along one edge

public void delay(int n)

{

long startDelay = System.currentTimeMillis();

long endDelay = 0;

while (endDelay - startDelay < n)

endDelay = System.currentTimeMillis();

}

}

Page 50: Chapter 8 Slides
Page 51: Chapter 8 Slides

// Java0825.java Cube Casestudy #7

// Stage #7 adds three methods that return the values of instance variables.

// They are methods <getX>, <getY> and <getSize>.

import java.awt.*;import java.applet.*;

public class Java0825 extends Applet

{

public void paint(Graphics g)

{

Cube cube = new Cube(g,50,50,50);

Cube cube = new Cube(g,400,300,200);

cube.draw(g);

System.out.println("Top Left X: " +

cube.getX());System.out.println("Top Left Y: " +

cube.getY());System.out.println("Cube Size: " +

cube.getSize());}

class Cube{

private int tlX;// topleft X coordinate of the Cube's position

private int tlY;// topleft y coordinate of the Cube's position

private int size;// the size of the cube along one edge

public int getX() { return tlX; }

public int getY() { return tlY; }

public int getSize() { return size; }}

Page 52: Chapter 8 Slides
Page 53: Chapter 8 Slides

Located behind the GUI window

Located at the bottom of JCreator

Page 54: Chapter 8 Slides

You might get this output when switching between the GUI and Text windows.

This happens if you drag the text window in front of the GUI window.

The GUI window will need to be refreshed which will cause the paint method to be called repeatedly.

Page 55: Chapter 8 Slides
Page 56: Chapter 8 Slides

Method SummaryClass (static)

Methods

Object (non-static)

Methods

public

Methods

private (helper)

Methods

void

Methods

return

Methods

Get / Accessor

Methods

Set / Modifier / Mutator

Methods

Default (no-parameter)

Constructors

Overloaded

Constructors

Page 57: Chapter 8 Slides
Page 58: Chapter 8 Slides

Important Note AboutSection 8.9

Section 8.9 is essentially the "Worked Out Exercises" section for Chapter 8 even though it is titled

“Do You Understand Methods & Parameters?”

This section is special because it is used withExercises 8.9

The PowerPoint file for these exercises isSlides08-KeyEx.ppt

which is not available to students because it is the answer key.

(Some teachers may still decide to share this file with their students for review purposes.)