I have a class that acts as a bettor, and in that class the bettor can place a bet in a method that creates a bet. However, the constructor of the bet class needs to take in the same reference of that bettor from the bettor class. How does one go about doing that?
Here is the code I was trying to use for this. I realize that making a new reference of the bettor class, but I thought I'd give it a try anyways
public Bet placeBet(Bet.BetType betType, double amount)
{
if(betType.equals(Bet.BetType.passBet))
{
this.bankroll=bankroll-amount;
return new PassBet(new Bettor(this.name,this.bankroll),amount);
}
else if(betType.equals(Bet.BetType.any7))
{
this.bankroll=bankroll-amount;
return new Any7Bet(new Bettor(this.name,this.bankroll),amount);
}
else if(betType.equals(Bet.BetType.hard8)||betType.equals(Bet.BetType.hard10))
{
this.bankroll=bankroll-amount;
return new HardWayBet(new Bettor(this.name,this.bankroll),amount);
}
return null;
}
while the PassBet Class looks as such (it is a subclass of the Bet class, which hold the Bettor reference and the amount bet).
public PassBet(Bettor b, double amount)
{
super(b,amount);
}
How would I go about passing the original Bettor as an argument into my PassBet subclass, which is then stored in superclass Bet?