Week 7.pptx - Object-Oriented Programming(OOP Week \u2013 07 Mar 16-20 2020 Instructor Basit Ali Email [email protected] Object-Oriented

Week 7.pptx - Object-Oriented Programming(OOP Week – 07...

This preview shows page 1 - 8 out of 29 pages.

Object-Oriented Programming (OOP) Week – 07 Mar 16-20, 2020 Instructor: Basit Ali Email: [email protected] Object-Oriented Programming (OOP)
Image of page 1
Recap – Inheritance Derived class inherits all the characteristics of the base class Besides inherited characteristics, derived class may have its own unique characteristics Major benefit of inheritance is reuse
Image of page 2
Generalization In OO models, some classes may have common characteristics We extract these features into a new class and inherit original classes from this new class This concept is known as Generalization
Image of page 3
Example – Generalization Circle color vertices radius move setColor computeArea Line color vertices length move setColor getLength Triangle color vertices angle move setColor computeArea
Image of page 4
Shape color vertices move setColor Circle radius computeArea Line length getLength Triangle angle computeArea
Image of page 5
Overriding A class may need to override the default behavior provided by its base class Reasons for overriding Provide behavior specific to a derived class Extend the default behavior Restrict the default behavior Improve performance
Image of page 6
Example – Specific Behavior color vertices draw move setColor Circle radius draw computeArea Line length draw Triangle angle draw computeArea
Image of page 7
Image of page 8

You've reached the end of your free preview.

Want to read all 29 pages?

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

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes