From: <ia...@co...> - 2005-03-02 13:01:56
|
Route traversal and revenue calculation: I wrote some perl to do this several years ago (avilable at http://www.cosgor.demon.co.uk/Perlbits/revenue.html), it doesn't take long. General comment: Has anyone read the 18xx-softdev archive yet? A lot of good ground was covered there (not all by me ;-)), and I think the discussions here would benefit from using this as a base. Specifically look at the thread(s) on a game definition file. Class structures, general and company: The abstract base class suggestion is almosts right. THe best practice is to define an interface, e.g. CompanyI, which defines the methods that all companies need to implement. You can then have an abstract base class and specific implementation classes for the most common types, but you are free to supply a completely different implementation without the need for inheriting from a specific (abstract base) class. All API methods which work with Company objects should then use CompanyI as the reference type unless a known sub-type is needed. Another advantage of this interface approach is that it permits one class to implement several different functions, e.g. an 1841 company class could implement 'TrainOwnerI', and 'ShareholderI'. In fact an 1830 public company could also implement 'ShareHolderI' to deal with any payments that it could receive from a private company which it owns. On the subject of share structure for companies, why not have a ShareI datatype, and have a 'List<ShareI> getShareStructure()' method on CompanyI? (Notes: a) use of Java5 Generics optional, b) choice of which collection to use also open) A method on ShareI could be 'int dividendForPayout(int payout)' which would calculate the dividend for a given share when the company distributes 'payout' amongst its shareholders. Other possible methods for a share could include 'double getSharePercent()', 'List getValidOwners()' - an 1830 private can be owned by a player or a company, but public company shares may only be held by players (or the bank pool, or the IPO). Iain. |