AbstractClasses - CIS3023: Programming Fundamentals for CIS...

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

View Full Document Right Arrow Icon
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Abstract Classes Course Lecture Slides 7 June 2010 “None of the abstract concepts comes closer to fulfilled utopia than that of eternal peace.” --Theodor W. Adorno
Background image of page 1

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

View Full DocumentRight Arrow Icon
Example Drawing Application Create different shapes: circle, rectangle, …
Background image of page 2
Circle -color: String -filled: Boolean -dateCreated: java.util.Date -radius: double +Circle() +Circle(radius: double) +getRadius(): double +setRadius(radius: double): void +getColor(): String +setColor(color: String): void +isFilled(): boolean +setFilled(filled: boolean): void +getDateCreated(): java.util.Date Rectangle -color: String -filled: Boolean -dateCreated: java.util.Date -width: double -height: double +Rectangle() +Rectangle(width: double, height: double) +getWidth(): double +setWidth(width: double): void +getHeight(): double +getColor(): String +setColor(color: String): void +isFilled(): boolean +setFilled(filled: boolean): void +getDateCreated(): java.util.Date
Background image of page 3

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

View Full DocumentRight Arrow Icon
G e o m e tric O b je c t -c o lo r: S trin g -filled : b o o lea n -d a teC rea ted : ja v a.u til.D ate + G e o m etric O b jec t() + g etC o lo r(): S trin g + setC o lo r(c o lo r: S trin g ): v o id + isF illed (): b o o lea n + setF illed (filled : b o o lea n ): v o id + g etD a teC rea ted (): ja v a .u til.D ate + to S trin g (): S trin g T h e c o lo r o f th e o b ject (d efa u lt: w h ite). In d ic ates w h eth er th e o b jec t is filled w ith a c o lo r (d efa u lt: fa lse). T h e d a te w h en th e o b jec t w a s c rea ted . C rea tes a G eo m etric O b jec t. R etu rn s th e c o lo r. S ets a n ew c o lo r. R etu rn s th e filled p ro p erty. S ets a n ew filled p ro p erty. R etu rn s th e d a teC rea ted . R etu rn s a strin g rep resen tatio n o f th is o b jec t. C irc le -ra d iu s: d ou b le + C irc le() + C irc le(ra d iu s: d o u b le) + g etR ad iu s(): d o u b le + setR ad iu s(rad iu s: d ou b le): v o id R e c ta n g le -w id th: d ou b le -h eig h t: d o u b le + R ec ta n g le() + R ec ta n g le(w id th : d ou b le, h eigh t: d o u b le) + g etW id th (): d ou b le + setW id th (w id th : d o u b le): v o id + g etH eig h t(): d o u b le + setH eig h t(h eigh t: d o u b le): v o id
Background image of page 4
So now we can instantiate a GeometricObject as follows: GeometricObject g = new GeometricObject(); But does it make sense ?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Solution Abstract Classes! Do not allow instantiation of GeometricObject class How? 6 Declare it as abstract as follows: public abstract class GeometricObject { }
Background image of page 6
G e o m e tric O b je c t -c o lo r: S trin g -filled : b o o lea n -d a teC rea ted : ja v a.u til.D ate + G e o m etric O b jec t() + g etC o lo r(): S trin g + setC o lo r(c o lo r: S trin g ): v o id + isF illed (): b o o lea n + setF illed (filled : b o o lea n ): v o id + g etD a teC rea ted (): ja v a .u til.D ate + to S trin g (): S trin g T h e c o lo r o f th e o b ject (d efa u lt: w h ite). In d ic ates w h eth er th e o b jec t is filled w ith a c o lo r (d efa u lt: fa lse). T h e d a te w h en th e o b jec t w a s c rea ted . C rea tes a G eo m etric O b jec t.
Background image of page 7

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

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

This note was uploaded on 05/27/2011 for the course CIS 3023 taught by Professor Dobbins during the Summer '08 term at University of Florida.

Page1 / 25

AbstractClasses - CIS3023: Programming Fundamentals for CIS...

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

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