필자는 변경이 허용되지 않는 함수로 작동하는 Player 클래스를 PHP로 작성해야합니다. 이 함수가 최대 값을 반환하는 방식으로이 클래스를 작성해야한다. 1-10 사이의 정수만 사용할 수 있습니다. 나는 단지 여기에 문제가있는 부분을 복사 : 나는 === 비교를 변경하지 못할 때문에PHP의 엄격한 비교
function CalcPlayerPoints($Player) {
$Points = 0;
foreach($Player as $key => $Value) {
switch ($key) {
case "profyears":
if($Value===true) // this should be true
$Points+=($Value*5); // this should take tha value I give in the class construct
break;
case "gentleman":
if($Value===true)
$Points+=10;
break;
}
}
return $Points; // that should be maximized
}
, 나는 profyears 속성을 초기화 할 수 없습니다입니다. 내가 10로 초기화 할 경우 문 있다면, 그것은이 기능이 있습니다
public function __construct() {
$this->gentleman = true;
$this->profyears = 10;
}
무엇이 당신의 질문입니까? – Crontab
$ value === true 일 경우, 통역사가 이것을 어떻게 5 배로 늘리 길 기대합니까? – JConstantine
'CalcPlayerPoints'는 어떻게 불려지나요? –