If you want to test if one outcome is equal to another, you probably want to
know if
The name of the outcome is the same
The odds of the outcome is the same
So, you'd implement it like so
class Outcome:
def __eq__(self, other):
if self.name == other.name and self.odds == other.odds:
Ben Ganzfried wrote:
Hey guys,
I'm trying to get a version of Roulette working and I had a quick question.
There's a quick answer and long answer. The quick answer is, you have to
refer to self.odds, not just odds. The long answer is below:
Here is my code:
[...]
Now whenever I try to ca
Updated inline. Check the updated definiton of winAmount.
Nick
On Tue, Jan 18, 2011 at 9:25 AM, Ben Ganzfried wrote:
> Hey guys,
>
> I'm trying to get a version of Roulette working and I had a quick
> question. Here is my code:
>
> class Outcome:
>
> def __init__(self, name, odds):
>
Hey guys,
I'm trying to get a version of Roulette working and I had a quick question.
Here is my code:
class Outcome:
def __init__(self, name, odds):
self.name = name
self.odds = odds
def winAmount(self, amount):
return odds*amount
def __eq__(self, other):