Skip to content

Instantly share code, notes, and snippets.

@edutrul
Created April 25, 2025 21:54
Show Gist options
  • Save edutrul/9ecb92f43c6324e4281515e410067044 to your computer and use it in GitHub Desktop.
Save edutrul/9ecb92f43c6324e4281515e410067044 to your computer and use it in GitHub Desktop.
Clase Robot php
<?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