Lecture 13-More on Subclasses

Lecture 13-More on Subclasses - CS1110 Lec 13 14 Oct 2010...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 1 CS1110 Lec. 13 14 Oct 2010 Another classy lecture: Casting about (secs 4.2, 4.3) 1. the class hierarchy 2. apparent and real classes 3. casting between classes 4. operator instanceof 5. function equals 6. abstract methods/classes (section 4.7, labs next week) Reading for next time: Sec. 2.3.8 and chapter 7 on loops. A4 due Saturday; make sure you're using Monday's a4.zip files (see assignments page on the course website for description of updates) Time management tip #42: schedule deadlines on your calendar; also schedule the time it will take to do the work. 2 Object Acct Cm Um the class hierarchy: Setting : Cmail ( Cm ) and Umail ( Um ) accounts. They have commonalities, like netIDs and an " alert " ability, so we make them subclasses of class Acct . b0 Acct Cm Cm(String) nid Acct(String) alert (String) getID() cc1 b1 Acct Um Um(String) nid Acct(String) alert (String) getID() uu2 [Note: Acct might best be made an abstract class; see last slide and next lab.] But, Cm and Um override Acct method alert(String), due to system differences. Cmail shows a “Web clip”; Umail creates a popup. alert (String) newClip(String) alert (String) popUp(String) Why do we keep drawing the overriden alert? 3 b0 Acct Cm Cm(String) alert(String) newClip(String) nid Acct(String) alert(String) getID() cc1 b1 Acct Um Um(String) alert(String) popUp(String) nid Acct(String) alert(String) getID() uu2 b0 The apparent (declared) type of a is Acct , and will always be Acct.
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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