Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator. The additions of
2 fractions should be equal to a fraction.
Use 1/2+1/3 as the test.
Hints:
Fraction f1, f2;
f1.add(f2);
1/2+1/3=5/6
我覺得這次的lab讓我對物件導向有更深的了解
尤其是在思考該怎麼樣用物件來思考
去寫成兩個物件相加(根據我思考的結果應該是這樣吧XD)
也突顯了我之前練習沒有去注意細節(這幾個Display都在家裡打過了= =")
雖然有挫折但是也慢慢感覺物件導向的一些威力了>///<
沒有留言:
張貼留言