Created
April 25, 2025 21:54
-
-
Save edutrul/9ecb92f43c6324e4281515e410067044 to your computer and use it in GitHub Desktop.
Clase Robot php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Robot { | |
private $size; | |
private $color; | |
private $price; | |
function __construct($size, $color, $price) { | |
$this->size = $size; | |
$this->color = $color; | |
$this->price = $price; | |
} | |
function setSize($size) { | |
$this->size = $size; | |
} | |
function setColor($color) { | |
$this->color = $color; | |
} | |
function setPrice($price) { | |
$this->price = $price; | |
} | |
function getSize() { | |
return $this->size; | |
} | |
function getColor() { | |
return $this->color; | |
} | |
function getPrice() { | |
return $this->price; | |
} | |
function getPriceCalculated() { | |
return $this->getPrice() * $this->getSize(); | |
} | |
} | |
$walle = new Robot(25, 'black', 100); | |
$walle->setSize(25); | |
$walle->setColor('orange'); | |
$walle->setPrice(100); | |
print $walle->getSize() . '<br>'; | |
print $walle->getColor() . '<br>'; | |
print $walle->getPrice() . '<br>'; | |
print 'Price calculated...: ' . $walle->getPriceCalculated(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment