Lec 14 Writing an Instantiable Class III
Agenda Review of Instantiable Classes Scope of variables Using this to override scope issues Lab: Creating a Car class for a video game
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
Structure of an Instantiable Dog Class class Dog size Dog getSize setSize bark Class Name Instance Varbls Methods Constructor method same name as class
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
Scope errors in code below
Memory Map Dog fido = new Dog(30);
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