[Bluej-discuss] Help me with classes - I suck continued........
Jason Sharpe
jason.sharpe1 at ntlworld.com
Thu Mar 1 00:58:47 GMT 2007
Okay, my programme that calculates pi based on a number of terms entered is nearly finished but all the reading and everything I've done is not helping me to understand how to make variables cross between classes.
Wallis's infinite product series ; pi = 2 x 2/1 x 2/3 x 4/3 x 4/5 x 6/5 x 6/7...... etc.
Confirms to the following class diagram
Picalculator
_________________
pi:double=0.0
_________________
+main(args:String[]
+getTerms():int
+calculatePi( terms:int):double
+displayPi(terms:int):void
_________________
'Method main() should call the other 3 methods in turn. All the methods are static. Note what parameters are passed and returned, if any. .... (stuff to do with how to programme the bit that calculates pi that I've already done)....
A static attribute pi is present to hold the value of pi; this can be assigned either once at the end of the kmethod call/ calculation, or repeatedly updated on each pass through the loop; note that the attribute has class scope and therefore visible throughout the class. Method displayPi() should simply use the value stored in the attribute pi and display it to screen, along with the number of terms used to arrive at this approximation and an appropriate message.'
cheer
chopp188
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20070301/34bb23bc/attachment.html
More information about the bluej-discuss
mailing list