{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AbstractClasses - CIS3023 Programming Fundamentals for CIS...

Info icon This 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
Image of page 1

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

View Full Document Right Arrow Icon
Example Drawing Application Create different shapes: circle, rectangle, …
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
Image of page 3

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

View Full Document Right 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
Image of page 4
So now we can instantiate a GeometricObject as follows: GeometricObject g = new GeometricObject(); But does it make sense ?
Image of page 5

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

View Full Document Right Arrow Icon
Solution Abstract Classes! Do not allow instantiation of GeometricObject class How? 6 Declare it as abstract as follows: public abstract class GeometricObject { }
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).
Image of page 7

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern