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 Class Name size color Instance Varbls Balloon inflate getSize getColor setColor pop Methods Constructor method same name as class Structure of an Instantiable Dog Class class Dog Class Name size Instance Varbls Dog getSize setSize bark 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 Class Name double speed; int turnRate; Instance Varbls Car getSpeed getTurnRate accelerate turnMoreLeft turnMoreRight Methods Constructor method same name as class
© Copyright 2026 Paperzz