Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface Hero
- {
- public function generateHashPass() ;
- public function getSpecialPoints() ;
- public function __construct(string $username, string $type, float $specialPoints, int $level);
- public function __toString();
- }
- class Demon implements Hero
- {
- private $username;
- private $type;
- private $specialPoints;
- private $level;
- public function generateHashPass()
- {
- $hashPass = strlen($this->username) * 217;
- return $hashPass;
- }
- public function getSpecialPoints()
- {
- return number_format(ceil($this->specialPoints) * $this->level , 1, '.', '');
- }
- public function __construct(string $username, string $type, float $specialPoints, int $level)
- {
- $this->username = $username;
- $this->type = $type;
- $this->specialPoints = $specialPoints;
- $this->level = $level;
- }
- public function __toString()
- {
- return "\"{$this->username}\" | \"{$this->generateHashPass()}\" -> {$this->type}" . PHP_EOL . $this->getSpecialPoints();
- }
- }
- class Archangel implements Hero
- {
- private $username;
- private $type;
- private $specialPoints;
- private $level;
- public function getSpecialPoints()
- {
- return ($this->specialPoints * $this->level);
- }
- public function generateHashPass()
- {
- return strrev($this->username) . strlen($this->username) * 21;
- }
- public function __construct(string $username, string $type, float $specialPoints, int $level)
- {
- $this->username = $username;
- $this->type = $type;
- $this->specialPoints = $specialPoints;
- $this->level = $level;
- }
- public function __toString()
- {
- return "\"{$this->username}\" | \"{$this->generateHashPass()}\" -> {$this->type}" . PHP_EOL . $this->getSpecialPoints();
- }
- }
- $line = explode(" | ", (fgets(STDIN)));
- $hero = null;
- if ($line[1] == "Demon"){
- $hero = new Demon($line[0], $line[1], round(floatval($line[2]), 14), intval($line[3]));
- }else{
- $hero = new Archangel($line[0], $line[1], intval($line[2]), intval($line[3]));
- }
- echo $hero;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement