Lecture8MoreInheritance

Lecture8MoreInheritance - More Inheritance CheckingAccount...

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

View Full Document Right Arrow Icon
More Inheritance
Background image of page 1

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

View Full DocumentRight Arrow Icon
CheckingAccount Inherits from BankAccount Keeps track of transactions each time a deposit or withdraw is done
Background image of page 2
Subclass Constructors BankAccount constructor : public BankAccount(double initialBalance){ balance = initialBalance; } CheckingAccount constructor: (won’t compile) public CheckingAccount (double amt) { transactionCount = 0; }
Background image of page 3

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

View Full DocumentRight Arrow Icon
Subclass Constructors BankAccount constructor : public BankAccount(double initialBalance){ balance = initialBalance; } CheckingAccount constructor: public CheckingAccount (double amt) { super(amt); transactionCount= 0; }
Background image of page 4
Constructor Rule 1. If super( args) is first statement in subclass constructor, the superclass constructor with matching parameter list will be invoked. 2. Otherwise, subclass constructor will automatically invoke superclass default constructor if it exists . 3. Otherwise, the subclass will not compile.
Background image of page 5

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

View Full DocumentRight Arrow Icon
CheckingAccount Create deposit and withdraw methods that increment the transactionCount variable then do the update to balance.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/13/2008 for the course CSC 216 taught by Professor Miller during the Spring '08 term at N.C. State.

Page1 / 18

Lecture8MoreInheritance - More Inheritance CheckingAccount...

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

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