From: Mark S. <mar...@gm...> - 2008-10-31 13:46:03
|
Erik, I pulled down your latest updates, and went to see if I could resolve the 18AL Bug report about not being able to upgrade tiles... and ran into a bug in your updates, that generates a NULL Pointer when trying to purchase the last Private (giving out the President's Share). It looks like in the StockRound Class, the setBuyableCerts routine (line 179) attempts to get the cost of the purchase with the call: price = comp.getParPrice().getPrice () * cert.getShares (); When I look at the PublicCompany.java Class, and the GetParPrice routine, it is checking the flag "hasParPrice" -- which is set to -TRUE- (this is wrong since the price has not been set yet via dialog). and then it returns: return parPrice != null? parPrice.getPrice() : null; and if -FALSE- it returns: return currentPrice != null ? currentPrice.getPrice () : null; In the -TRUE- Case, it will return the parPrice StockSpace. In the -FALSE- case, it is returning the Current Stock Value, and not the Par Price Value which is implied by the routine name. So if the -hasParPrice- variable is NOT set, it tries to get the currentPrice. And this should not be set either... This routine looks wierd. Would it make sense to add a routine like: public int getParPrice () { /* Get the ParPrice StockSpace with the first getPrice call, and get the actual int value with the second call */ return parPrice != null ? parPrice.getPrice().getPrice() : 0; } So if you want the Int Value of the Par Price... you call the routine, and allow JAVA to use the appropriate routine? In this case like 179 of StockRound.java would be: price = comp.getParPrice () * cert.getShares (); Note, it Appears in 1830 I can set price for B&O, and buy it, but once the Stock Round starts, I have no stocks available to buy in the IPO. And I get the same NULL Pointer Exception on Line 179 of Stock Round. Mark On Thu, Oct 30, 2008 at 5:53 PM, John A. Tamplin <ja...@ja...> wrote: > On Thu, 30 Oct 2008, Erik Vos wrote: > > > I didn't find it worthwhile to invent an XML > > structure to make all these rules configurable. > > I agree -- since Java can load classes dynamically, it is better to write > code in a real programming language than trying to extend XML to be a > programming language. > > A long time ago I used the same approach for a Java implementation of > Cosmic Encounter (the cards all have arbitrary powers that alter the rules > of the game). New cards could be loaded by just including additional > jars in a directory, and the game loaded all the cards that were defined > there. Perhaps Rails could be structured such that support for new games > could be delivered the same way, once the core supported all the > mechanisms that any of the games might need. > > -- > John A. Tamplin ja...@ja... > 770/436-5387 HOME 4116 Manson Ave > Smyrna, GA 30082-3723 > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |