How to implement a class named Dragonball. This class must have an attribute named ballCount (which starts from 0) and a method iFoundaBall. When iFoundaBall is called, ballCount is increased by one. If the value of ballCount is equal to seven, then the message You can ask your wish is printed, and ballCount is reset to 0. How would you implement this class?

Submitted by: Muhammad
<?php
class dragonBall{
private $ballCount;

public function __construct(){
$this->ballCount=0;
}

public function iFoundaBall(){
$this->ballCount++;
if($this->ballCount===7){
echo "You can ask for your wish.";
$this->ballCount=0;
}
}
}
?>
This question will evaluate a candidate’s knowledge about OOP.
Submitted by: Muhammad

Read Online PHP Community Marketing Expert Job Interview Questions And Answers