How to make more objects of a class

The class CCar is just a kind of template. The object is a specific car created based on CCar.
You can make a lot of cars!

The Program

If Button1 (street) is clicked the label shows the values of the street-object.
If Button2 (offroad) is clicked the label shows the values of the offroad-object.

The Code:

Fmain.class:

PUBLIC street AS CCar
PUBLIC offroad AS CCar
 
'two objects of the same type are declared
STATIC PUBLIC SUB Main()
  DIM hForm AS Fmain
  hForm = NEW Fmain
  hForm.show
END

PUBLIC SUB _new()
 
'now the two objects are made
'the constructor of the class needs the attributes!
  street = NEW CCar("ford", 100, 200.45)
  offroad = NEW CCar("jeep", 150, 2876.94)
END


PUBLIC SUB Button1_Click()
  TextLabel1.Text=
    street.getBrand() & "<br>" &
    Str(street.getPS_Power()) & " PS<br>" &
    Str(street.getKW_Power()) & " KW<br>" &
    Str(street.getPrice())
END

PUBLIC SUB Button2_Click()
  TextLabel1.Text=
    offroad.getBrand() & "<br>" &
    Str(offroad.getPS_Power()) & " PS<br>" &
    Str(offroad.getKW_Power()) & " KW<br>" &
    Str(offroad.getPrice())
END

Ccar.class

The Source

Download



Referenced by :