建立一個名爲Apple的類,一個私有的成員變量int price。在構造函數中初始化該參數,建立一個名爲int getValue(int weight) 方法,返回蘋果價值(price*weight

建立一個名爲Apple的類,一個私有的成員變量int price。在構造函數中初始化該參數,建立一個名爲int getValue(int  weight) 方法,返回蘋果價值(price*weight);java 例如:函數 測試 Result Apple a =new Apple(5); System.out.println(a.getValue(10)); 50   class Apple{
相關文章
相關標籤/搜索