PHPのテストです。
チャンネルは1から12の間で設定してください<?php $tv = new Television(); $tv->setChannel(20); print('現在のチャンネルは '.$tv->getChannel().'<br />' ); $tv->setChannel(10); print('現在のチャンネルは '.$tv->getChannel().'<br />' ); class Television { private $channelNo = 8; public function setChannel( $channel ) { if ( ($channel >= 1) and ($channel <= 12) ) { $this->channelNo = $channel; } else { print( 'チャンネルは1から12の間で設定してください<br />' ); } } public function getChannel() { return $this->channelNo; } } ?>