From: "Weirich, James" Date: 2003-09-12T23:57:15+09:00 Subject: Re: OO Challenge I'll throw in my version. Logically it is structured very much like Robert Klemme's except that I made lighter weight choices for some of the abstractions. For example, I use simple procs for the tax groups and my TaxPayer is Struct based. What is really interesting is that despite the differences in representation, the last bits of our programs are identical except for minor spelling differences. Here's the code. ----------------------------------------------------- Soldier = proc { |p| p.salary / 10.0 } Professor = proc { |p| p.salary / 15.0 + 100 } TaxPayer = Struct.new(:salary, :tax_classes) class TaxPayer def tax tax_classes.collect { |tc| tc.call(self) }.max end end taxpayers = [ TaxPayer.new(3000, [Soldier]) TaxPayer.new(5000, [Professor]) TaxPayer.new(6000, [Professor, Soldier]) ] Taxpayers.each { |tp| printf "%0.2f\n", tp.tax } ---------------------------------------------------- Disclaimer: I don't believe this example says anything deep or significant about OO verse non-OO. -- -- Jim Weirich / Compuware -- FWP Capture Services -- Phone: 859-386-8855