<?php
class TriangleFigure {
    // プロパティはprivate権限で定義する
    private float $base;
    private float $height;

    // プロパティ値を初期化する
    public function __construct() {
        $this->setBase(1);
        $this->setHeight(1);
    }

    // baseプロパティのゲッター（取得）メソッド
    public function getBase() : float {
        return $this->base;
    }

    // baseプロパティのセッター（設定）メソッド
    public function setBase(float $base) : void {
        if ($base <= 0) {
            throw new Exception('baseは正数で指定します。');
        }
        $this->base = $base;
    }

    
    public function getHeight() : float {
        return $this->height;
    }
    
    public function setHeight(float $height) : void {
        if ($height <= 0) {
            throw new Exception('heightは正数で指定します。');
        }
        $this->height = $height;
    }



    // プロパティ値をもとに面積を取得する
    public function getArea(): float {
        return $this->getBase() * $this->getHeight() /2;
    }
}