Saturday, June 2, 2012

ITC280 Update 9

What I learned on Week 9 of the ITC280 class?


1) Here is a stub of a class:

class Car{}


2) Here is a simple Car object created from the car class:

$myCar = new Car();


echo $myCar->mph;




class Car


{


 public $color = "";


 public $mph = 0;


 public $price = 0;


 public $model = "";





}


3) We add a constructor to be able to load data into our object

$myCar = new Car("ferrari",100000,140,"red");


echo "MPH: " . $myCar->mph . "<br />";


echo $myCar->model;


echo $myCar->color;


echo $myCar->price;




class Car


{


 public $color = "";


 public $mph = 0;


 public $price = 0;


 public $model = "";





 function Car($model,$price,$mph,$color)


 {


  $this->model = $model;


  $this->price = $price;


  $this->mph = $mph;


  $this->color = $color;



4) We can Create accessor methods (get/set) to allow read/write access;

function getMPH()


  {//will allow read access to a private property


  return $this->mph;


 }

NOTES:

It's almost the end of this class and I haven't decided on what will my final project be. Should I use the theme we used in class or use something different? That is a question I cannot answer but hey, how many lessons left before we do the final project? What should I do? I'm still stuck and I can't figure out what will my final project be...

Only one way to find out...soon...

1 comment:

Bill said...

Feng,

I'm grading the ITC280 at this time. I'm grading all the way through A12, even though that assignment is not due until next week.

Everything looks great through A12!

Great job! Thanks for all your hard work this quarter!

Bill