[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
Back to Text Composition Lab. On to Arrays.
Held: Friday, March 4, 2005
Summary: Today we consider inheritance, a key aspect of object-oriented design.
Related Pages:
Due
Notes:
Overview:
Surrounded object from TextLines, from HorizontallyComposed blocks of text, and from anything else that implements TextBlock
Surrounded once and it works for all of the above.
TextBlock with something like the following
for (int i = 0; i < tb.getLines(); i++) pen.println(tb.getLine(i));
TextBlock. That seems wasteful.
Point classes, all of them might share x and y fields.
subclass.
superclass.
multiple inheritance.
ColoredPoints, which are points that add colors.
Integer is a Number.
extends keyword (rather than some variant of is-a.
public class ColoredPoint
extends Point
{
} // class ColoredPoint
public class Integer
extends Number
{
...
} // class Integer
DrawableObject obj = new Circle(); Number n = new Integer(5);
public void drawWithStrangeColors(DrawableObject obj) {
...
} // drawWithStrangeColors(DrawableObject)
...
public Number add(Number val1, Number val2) {
...
} // add(Number,Number)
...
drawWithStrangeColors(new Circle());
...
Number result = add(new Integer(5), new Integer(2));
super(parameters) as the first line of your
subclass constructor.
abstract classes.
abstract before the class name in the class definition.
abstract before the method name.
Back to Text Composition Lab. On to Arrays.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Wed May 11 10:55:58 2005.
The source to the document was last modified on Mon Jan 24 10:17:07 2005.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2005S/Outlines/outline.24.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby