0
問題
使用面向對象的設計來設計一個名爲Circle的類,它將接收圓的直徑,並計算並顯示該圓的周長和麪積。設計類表...寫一個算法每個操作...編寫一個測試或驅動程序算法測試解決方案Obejct Oriented Design Class Circle - 我做對了嗎?
Class Table
Class
Circle
Attributes
diameter
Responsibilities
receive diameter
calculate circumference
calculate area
display circumference
display area
Operations
+setDiameter()
-calculateCircumference
-calculateArea
+displayCircumference
+display Area
Algorithm
Class Circle
diameter1
setDiameter (inDiameter1)
Diameter1=inDiameter1
END
displayDiameter()
calculateCircumference (Circumference)
calculateArea (Area)
Display "The Diameter is", Diameter1
Display "The Circumference is", Circumference
Display "The Area is", Area
END
calculateCircumference (Circumference)
Circumference=Diameter1*3.14
END
calculateArea (Area)
Area=(Diameter1*Diameter1)*3.14
END
Test or Driver Algorithm
Create Circle as NewCircle()
testCircle()
inDiameter1=5
Circle.setDiameter (inDiameter1)
Circle.displayCircumference()
Circle.displayArea()
我這樣做嗎???
這是什麼語言? – RoflcoptrException 2011-04-17 19:04:07
@Roflcoptr我會想象類和算法的設計將是語言不可知的。 – corsiKa 2011-04-17 19:05:27
@glowcoder是的,我也這麼想過,但是我被END關鍵字激怒了。 – RoflcoptrException 2011-04-17 19:06:17