Download presentation
Presentation is loading. Please wait.
Published byEmily Peters Modified over 9 years ago
1
Repetition in Control flow; Array data structure Chapter 5
2
Key Class Key //class name //Data private boolean isDown; // key status not down or down private String key; //key name private String sound; // key sound //methods //constructor: to initialize the characteristic of the key public Key (String keyName, String soundFile) // create a Key object and initialize // other methods public void act () // mimic the motion of the key going down: animating the key public void play() // play the sound corresponding to the key: producing the sound ….
3
Piano Class Piano //data whiteKeys // keyboard keys corresponding to white keys whiteNotes //wave files for white keys blackKeys blackNotes //methods Default constructor // instantiate Key object for the keys and place them on the Piano public void makeKeys()
4
Classes and Relationships Piano Actor Key IS A Inheritance relationship HAS A Aggregation relationship1 n
5
New Concepts Classes and relationships: is-a and has-a relationships Array data structure to store key information (letter, sound) Loop control structure to repeat operations/instructions
6
10 things We will do it next class
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.