Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lec 14 Writing an Instantiable Class III. Agenda Review of Instantiable Classes Scope of variables Using this to override scope issues Lab: Creating a.

Similar presentations


Presentation on theme: "Lec 14 Writing an Instantiable Class III. Agenda Review of Instantiable Classes Scope of variables Using this to override scope issues Lab: Creating a."— Presentation transcript:

1 Lec 14 Writing an Instantiable Class III

2 Agenda Review of Instantiable Classes Scope of variables Using this to override scope issues Lab: Creating a Car class for a video game

3 Recall Structure of an Instantiable Class class Balloon size color Balloon inflate getSize getColor setColor pop Class Name Instance Varbls Methods Constructor method same name as class

4 Structure of an Instantiable Dog Class class Dog size Dog getSize setSize bark Class Name Instance Varbls Methods Constructor method same name as class

5 Now we'll begin ScopeThisDog Demo create Dog and MainApp classes show how scope errors can cause compile failure scope of – instance variables, parameters, and local variables Using keyword this to resolve scope issues in Class definition files

6 Scope errors in code below

7 Memory Map Dog fido = new Dog(30);

8 Lab14 You write a Car Class class Car double speed; int turnRate; Car getSpeed getTurnRate accelerate turnMoreLeft turnMoreRight Class Name Instance Varbls Methods Constructor method same name as class


Download ppt "Lec 14 Writing an Instantiable Class III. Agenda Review of Instantiable Classes Scope of variables Using this to override scope issues Lab: Creating a."

Similar presentations


Ads by Google