Advertisement
DimitarS

MooD 83/100

Mar 12th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. <?php
  2. interface Hero
  3. {
  4. public function generateHashPass() ;
  5.  
  6. public function getSpecialPoints() ;
  7.  
  8. public function __construct(string $username, string $type, float $specialPoints, int $level);
  9.  
  10. public function __toString();
  11.  
  12. }
  13.  
  14. class Demon implements Hero
  15. {
  16. private $username;
  17. private $type;
  18. private $specialPoints;
  19. private $level;
  20.  
  21. public function generateHashPass()
  22. {
  23. $hashPass = strlen($this->username) * 217;
  24. return $hashPass;
  25. }
  26.  
  27. public function getSpecialPoints()
  28. {
  29. return number_format(ceil($this->specialPoints) * $this->level , 1, '.', '');
  30. }
  31.  
  32. public function __construct(string $username, string $type, float $specialPoints, int $level)
  33. {
  34. $this->username = $username;
  35. $this->type = $type;
  36. $this->specialPoints = $specialPoints;
  37. $this->level = $level;
  38. }
  39.  
  40. public function __toString()
  41. {
  42. return "\"{$this->username}\" | \"{$this->generateHashPass()}\" -> {$this->type}" . PHP_EOL . $this->getSpecialPoints();
  43. }
  44. }
  45. class Archangel implements Hero
  46. {
  47. private $username;
  48. private $type;
  49. private $specialPoints;
  50. private $level;
  51.  
  52. public function getSpecialPoints()
  53. {
  54. return ($this->specialPoints * $this->level);
  55. }
  56.  
  57. public function generateHashPass()
  58. {
  59. return strrev($this->username) . strlen($this->username) * 21;
  60. }
  61.  
  62. public function __construct(string $username, string $type, float $specialPoints, int $level)
  63. {
  64. $this->username = $username;
  65. $this->type = $type;
  66. $this->specialPoints = $specialPoints;
  67. $this->level = $level;
  68. }
  69.  
  70. public function __toString()
  71. {
  72. return "\"{$this->username}\" | \"{$this->generateHashPass()}\" -> {$this->type}" . PHP_EOL . $this->getSpecialPoints();
  73. }
  74. }
  75.  
  76. $line = explode(" | ", (fgets(STDIN)));
  77. $hero = null;
  78. if ($line[1] == "Demon"){
  79. $hero = new Demon($line[0], $line[1], round(floatval($line[2]), 14), intval($line[3]));
  80. }else{
  81. $hero = new Archangel($line[0], $line[1], intval($line[2]), intval($line[3]));
  82. }
  83.  
  84. echo $hero;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement