在之前的課程裡,我們學到了Rectangle這個class,裡面有width和height這兩個成員變數。 如果我們需要一個Brick的class,需要用到width,height和thickness這三個成員變數,所以 我們可以利用繼承的概念來讓Brick重複使用Rectangle的成員變數。 請寫Rectangle和Brick這兩個class,並讓Brick繼承Rectangle,此外在Rectangle裡請寫一個成員 函式int area()回傳矩形面積,在Brick裡寫一個成員函式int volume()回傳磚塊體積。 範例: 若在主程式裡宣告四個物件: Rectangle a = new Rectangle(); Rectangle b = new Rectangle(2,3); Brick c = new Brick(); Brick d = new Brick(2,3,1); 最後輸出結果: the area of rectangle a = 1 the area of rectangle b = 6 the area of brick c = 1 the area of brick d = 6 the volume of brick c = 1 the volume of brick d = 6