Lecture 13-More on Subclasses

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

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: 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 1. operator instanceof 2. function equals 3. 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 overridden 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....
View Full Document

{[ snackBarMessage ]}

Page1 / 11

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

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

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