Algorithms and OOD (CSC 207 2014F) : EBoards

CSC207.01 2014F, Class 17: Pause for Breath


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Miscellaneous

Questions

Lessons from the Inheritance Lab

Some questions and lessons from the lab on inheritance.

Consider these declarations

    public class Super
    {
      ...;
    } // class Super
    public class Sub
      extends Super
    {
      ...;
    } // class Sub
    Super fluous = new Super(...);
    Sub marine = new Sub(...);

Suppose we write

    Super fluous = new Super(...);
    Sub marine = new Sub(...);
    Super sonic = marine;
    pen.println(sonic.toString());

Examples in /examples/SuperSub

Constructors

Additional Information

Four (or more) Mechanisms for Doubling Counters

Remember

public class Counter
{
  ...
  public String toString()
  {
   ...
  } // toString()

  public void increment()
  {
    ...
  } // increment()

  public void reset()
  {
    ...
  } // reset()
} // class Counter

Suppose we want another counter that counts twice as fast. What approaches might we take?