Lec7 OO Inheritance - 9/16/2010 Todays Announcements EE322C...

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

View Full Document Right Arrow Icon
9/16/2010 1 EE322C Data Structures Sarfraz Khurshid Lecture 7 Sep 16, 2010 Today’s Announcements Assignment 1 code due: sunday, 11:59pm Exam 1 on Sep 30, 12:30pm, in class Today continue OO basics OO inheritance inner classes Scoping Resolution When resolving a variable, say “x”: First: try to find a local variable with that name Second: try to find a parameter with that name Third: try to find a field with that name in the class Fourth: try to find a global variable with that name Last: Give up and print an error message “no such variable” Example usage of BankAccount BankAccount class Driver (client) Program class Models bank accounts. It defines the instance variables, and Uses the BankAccount class to create and manipulate bank methods to be used on all objects created from this class account objects. The main method is in here. Program BankAccountDriver.java public class BankAccountDriver { public static void main (String[ ] args) { BankAccount myAccount = new BankAccount(10000); final double INTEREST_RATE = 5.0; int years = 10; double interest; // compute and add in interest for 10 years for ( int i =1; i <= years; i++) { interest = myAccount.getBalance ( ) * INTEREST_RATE / 100; myAccount.deposit(interest); System. out .println( "Balance after year " + i + " is $" + myAccount.getBalance( )); } } } OO Design Tips Separate the definition of a class from the use of that class Nouns in the problem statement are candidates
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/02/2010 for the course EE 322C taught by Professor Nettles during the Spring '08 term at University of Texas at Austin.

Page1 / 4

Lec7 OO Inheritance - 9/16/2010 Todays Announcements EE322C...

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

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