echo $this->name . " needs more food than that!"; echo "<br>"; } else { echo $this->name . " is fully fed!"; echo "<br>"; } } public function howOld() { echo $this->name . " is " . $this->age . " years old."; echo "<br>"; echo $this->name . " is " . $this->age . " cat years old!"; echo "<br>"; } } $cat1 = new Cat("Little Buddy", 2, 8); $cat2 = new Cat("Sneaky Pete", 0, 2); $cat1->howOld(); $cat1->feedCat(6); echo $cat2->name; echo "<br>"; ?> </body> </html>
} } public function howOld() { echo $this->name . " is " . $this->age . " years old."; echo "<br>"; echo $this->name . " is " . $this->age . " cat years old!"; echo "<br>"; } } $cat1 = new Cat("Little Buddy", 2, 8); $cat2 = new Cat("Sneaky Pete", 0, 2); $cat3 = new Cat("whiskers", 1, 2); $cat1->howOld(); $cat1->feedCat(6); $cat3->howOld(); echo $cat2->name; echo "<br>"; echo "TESTING!!!!"; $student1 = new Student('Harry', 'Potter', 17); $student2 = new Student('Charlie', 'Brown', 16); $student3 = new Student('Gary', 'Coleman', 15); echo $student1->firstName; echo "<br>"; echo $student1->lastName; echo "<br>"; echo $student1->age; echo "<br>"; //Rahjon's class class Student {
{ echo $this->name . " is " . $this->age . " years old."; echo "<br>"; echo $this->name . " is " . $this->age . " cat years old!"; echo "<br>"; } } $cat1 = new Cat("Little Buddy", 2, 8); $cat2 = new Cat("Sneaky Pete", 0, 2); $cat3 = new Cat("Jim", 1, 3); $cat4 = new Cat("Tom", 2, 5); $cat5 = new Cat("Kit", 120, 500); $cat1->howOld(); $cat1->feedCat(6); $cat3->howOld(); $cat5->howOld(); echo $cat2->name; echo "<br>"; // =========== NEW CLASS ========== class Car { public $brand; public $price; public function __construct($_brand, $_price) { $this->brand = $_brand; $this->price = $_price; } } $car1 = new Car("458 Italia", Ferrari, 450000); $car2 = new Car("Camaro", Camaro, 23000);