Section 13.8. Exercise


13.8. Exercise

You can find the answer to this exercise in "Answer for Chapter 13" in the Appendix.

13.8.1. Exercise [45 min]

Modify the RaceHorse class to get the previous standings from a DBM hash (keyed by the horse's name) when the horse is created, and update the standings when the horse is destroyed. For example, running this program four times:

 my $runner = RaceHorse->named('Billy Boy'); $runner->won; print $runner->name, ' has standings ', $runner->standings, ".\n"; 

should show four additional wins. Make sure that a RaceHorse still does everything a normal Horse does otherwise.

For simplicity, use four space-separated integers for the value in the DBM hash.




Intermediate Perl
Intermediate Perl
ISBN: 0596102062
EAN: 2147483647
Year: N/A
Pages: 238

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net