Lecture5-Jan27-Abstract

Lecture5-Jan27-Abstract - 1 1 / 41 COP 3503 SPRING 2012...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
1 / 41 COP 3503 SPRING 2012 Shayan Javed Lecture 5 Programming 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 / 41 Abstract Classes
Background image of page 2
3 / 41 Abstract classes From the previous lecture: public class GeometricObject { protected String Color; protected String name; protected float area; // Constructors…
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 / 41 Abstract classes So we can do: GeometricObject gObj = new GeometricObject (“AnObject, Red”);
Background image of page 4
5 / 41 Abstract classes So we can do: GeometricObject gObj = new GeometricObject (“AnObject, Red”); But does it make sense to do this? What is a “GeometricObject” by itself?
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 / 41 Abstract classes Solution: Make it abstract !
Background image of page 6
7 / 41 Abstract classes Solution: Make it abstract ! public abstract class GeometricObject {
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 / 41 Abstract classes Used for defining classes for “ abstract concepts. (‘GeometricObject’, ‘Animal’, etc.)
Background image of page 8
9 / 41 Abstract classes Used for defining classes for “ abstract concepts. (‘GeometricObject’, ‘Animal’, etc.) Then define “ concrete ” concepts as subclasses. (Circle, Rectangle, etc.)
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 / 41 Abstract classes Used for defining classes for “ abstract concepts. (‘GeometricObject’, ‘Animal’, etc.) Then define “ concrete ” concepts as subclasses. (Circle, Rectangle, etc.) More strictness = less room for ambiguity/error.
Background image of page 10
11 / 41 Abstract classes Every GeometricObject has an area.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
12 / 41 Abstract classes Every GeometricObject has an area. But getArea() defined differently for concrete objects.
Background image of page 12
Abstract classes Every GeometricObject has an area. But
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/15/2012 for the course COP 3503 taught by Professor Staff during the Spring '12 term at University of Florida.

Page1 / 42

Lecture5-Jan27-Abstract - 1 1 / 41 COP 3503 SPRING 2012...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online