Chapter 7
From Object-Oriented Designs to API’s

   7.1 Basic Designs
   7.2 Private and Shared Features
   7.3 Inheritance
   7.4 Assignment #8: Programming APIs

7.1 Basic Designs

Bulb
status
flip
class Bulb { 
  boolean status; 
  Bulb () { } 
  void flip (){ } 
} 

7.2 Private and Shared Features

Bulb
status
average
flip
flipAll
class Bulb { 
  boolean status; 
     /** average life in hours per bulb */ 
  static int average; 
  Bulb () { } 
     /** a switch for each bulb */ 
  void flip (){ } 
     /** a centeral switch for all the bulbs */ 
  static void flipAll (){ } 
} 

7.3 Inheritance

Bulb
status
flip
NeonBulb
length
 
RegularBulb
radius
 
class Bulb { 
  boolean status; 
  Bulb () { } 
  void flip (){ } 
} 
class NeonBulb extends Bulb { 
  double length; 
} 
class regularBulb extends Bulb { 
  double radius; 
} 

7.4 Assignment #8: Programming APIs

Due: We, Apr 23, midnight

For each of our Clock, Car, and Pet designs, prepare a file which defines the relevant APIs. The files should be compilable under javadoc -package into web pages that list the different features together with appropriate comments.

Clock
hr
min
sec
set
tick
showTime
Car
gas
consumption
fill()
fill(i)
drive(x)
Pet
weight
eat
pooh

Assume ‘lab8’ for the submit program.

Note: Files that fail to compile, and execute when applicable, will not be examined. They will be awarded a grade of 0 points.

Q&A