Advertisement
Kutov

Untitled

Oct 23rd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. <?php
  2.  
  3. interface Players{
  4. public function hashedPassword();
  5. }
  6. class Demon implements Players{
  7.  
  8. private $username;
  9. private $special_points;
  10. private $level;
  11. private $password;
  12. public function __construct( $username, $special_points, $level)
  13. {
  14. $this->setUsername($username);
  15. $this->special_points=$special_points;
  16. // var_dump($this->special_points);
  17. $this->setLevel($level,$special_points);
  18. $this->hashedPassword();
  19. }
  20.  
  21. public function setUsername(string $username): void
  22. {
  23. $this->username = $username;
  24. }
  25.  
  26. public function setCharType(): void
  27. {
  28. $this->char_type = "Demon";
  29. }
  30. public function setSpecialPoints(float $special_points): void
  31. {
  32. var_dump($special_points);
  33. $this->special_points = (float)$special_points;
  34. var_dump($this->special_points);
  35. }
  36. public function setLevel( $level): void
  37. {
  38. $this->level = $level;
  39. }
  40. public function getUsername()
  41. {
  42. return $this->username;
  43. }
  44. public function getCharType(): string
  45. {
  46. return $this->char_type;
  47. }
  48. public function getSpecialPoints(): float
  49. {
  50. return $this->special_points;
  51. }
  52. public function getLevel(): float
  53. {
  54. return $this->level;
  55. }
  56.  
  57. public function hashedPassword()
  58. {
  59. $this->password=217*strlen($this->username);
  60. }
  61. public function getPassword():int
  62. {
  63. return $this->password;
  64. }
  65. public function __toString(){
  66. $count=explode(".",$this->special_points);
  67. $format=$count[1];
  68. $level=number_format($this->getLevel(), strlen($format),'.','');
  69. $spl=($this->special_points*$level);
  70. $spl=number_format($spl,strlen($format),'.','');
  71. return '"'.$this->getUsername().'" | "'.$this->getPassword().'" -> Demon '.PHP_EOL.$spl;
  72. }
  73. }
  74. class Archangel implements Players{
  75. //<username> | <character type> | <special points> | <level>
  76. /**
  77. * @var string
  78. */
  79. private $username;
  80. /**
  81. * @var string
  82. */
  83. private $char_type;
  84. /**
  85. * @var int
  86. */
  87. private $special_points;
  88. /**
  89. * @var int
  90. */
  91. private $level;
  92. /**
  93. * @var string
  94. */
  95. private $password;
  96. /**
  97. * Demon constructor.
  98. * @param string $username
  99. * @param string $char_type
  100. * @param int $special_points
  101. * @param int $level
  102. */
  103. public function __construct(string $username, int $special_points, int $level)
  104. {
  105. $this->setUsername($username);
  106. $this->setSpecialPoints($special_points);
  107. $this->setLevel($level,$special_points);
  108. $this->hashedPassword();
  109. }
  110. /**
  111. * @param string $username
  112. */
  113. public function setUsername(string $username): void
  114. {
  115. $this->username = $username;
  116. }
  117.  
  118. /**
  119. * @param string $char_type
  120. */
  121. public function setCharType(string $char_type): void
  122. {
  123. $this->char_type = "Archangel";
  124. }
  125.  
  126. /**
  127. * @param int $special_points
  128. */
  129. public function setSpecialPoints(int $special_points): void
  130. {
  131. $this->special_points = $special_points;
  132. }
  133.  
  134. /**
  135. * @param int $level
  136. */
  137. public function setLevel(int $level,int $special_points): void
  138. {
  139. $this->level = $level*$special_points;
  140. }
  141.  
  142. /**
  143. * @return string
  144. */
  145. public function getUsername(): string
  146. {
  147. return $this->username;
  148. }
  149.  
  150. /**
  151. * @return string
  152. */
  153. public function getCharType(): string
  154. {
  155. return $this->char_type;
  156. }
  157.  
  158. /**
  159. * @return int
  160. */
  161. public function getSpecialPoints(): int
  162. {
  163. return $this->special_points;
  164. }
  165.  
  166. /**
  167. * @return string
  168. */
  169. public function getLevel(): int
  170. {
  171. return $this->level;
  172. }
  173.  
  174. public function hashedPassword()
  175. {
  176. $total=strlen($this->username)*21;
  177. $this->password='"'.strrev($this->username).$total.'"';
  178. }
  179. public function getPassword():string
  180. {
  181. return $this->password;
  182. }
  183. public function __toString(){
  184. return '"'.$this->getUsername().'" | '.$this->getPassword().' -> Archangel '.PHP_EOL.$this->getLevel();
  185. }
  186. }
  187. list($username,$char_type,$special_points,$level)=explode(" | ",readline());
  188. //var_dump($special_points);
  189. //if($char_type=="Demon"){
  190. // $special_points=(float)$special_points;
  191. //
  192. //}else{
  193. // $special_points=(int)$special_points;
  194. //}
  195.  
  196. $player =new $char_type($username,$special_points,$level);
  197. echo $player;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement