くだすれPHP(超初心者用)3
■ このスレッドは過去ログ倉庫に格納されています
0021nobodyさん
2007/11/03(土) 18:39:13ID:???gattai(Human ore, Human anata) {
return ore.gattai(anata);
}
みたいな?
こういうことやるためには
HumanクラスにgetTypeメソッド
public function getType() {
return "Human";
}
を実装
function gattai($ore, $anata) {
if(is_Human($ore) && is_Human($anata)) {
return $ore->gattai($anata);
} else {
throw Exception();
}
}
function is_Human($human) {
return $human->getType() == "Human" ? true : false;
}
とでもしないと駄目なんかね。
■ このスレッドは過去ログ倉庫に格納されています