Inheritance and Polymorphism help
what is move method in CLASS?
I tried to search in google but no luck:
"Create a move method in the Shape class that accepts two values. These values are added to x and y attributes to simulate moving the shape."
this is the code I got so far (please fix me if something is wrong with this code):
class shape {
private $name;
private $x;
private $y;
function __construct($x , $y) {
$this->X = $x;
$this->y = $y;
}
public function setName($name) {
$this-> name = $name ;
}
public function getName() {
return $this-> name ;
}
public function setX($x) {
$this-> x = $x ;
}
public function getX(){
return $this-> x ;
}
public function setY($y){
$this-> Y = $y;
}
public function getY(){
return $this-> Y ;
}
thanks
hale
what is move method in CLASS?
I tried to search in google but no luck:
"Create a move method in the Shape class that accepts two values. These values are added to x and y attributes to simulate moving the shape."
this is the code I got so far (please fix me if something is wrong with this code):
class shape {
private $name;
private $x;
private $y;
function __construct($x , $y) {
$this->X = $x;
$this->y = $y;
}
public function setName($name) {
$this-> name = $name ;
}
public function getName() {
return $this-> name ;
}
public function setX($x) {
$this-> x = $x ;
}
public function getX(){
return $this-> x ;
}
public function setY($y){
$this-> Y = $y;
}
public function getY(){
return $this-> Y ;
}
thanks
hale
Last edited: