public override bool Equals(Object obj) { if (obj == this) { return(true); } if (obj == null || this.GetType() != obj.GetType()) { return(false); } Punter u = (Punter)obj; return(base.Equals(obj) && this.BetESSCoins == u.getBetESSCoins() && OpenBetsListEquals(u.getOpenBets()) && ClosedBetsListEquals(u.getClosedBets())); }
/// <summary> /// Closes the bets of a specified event, notifies the punters which bet on that particular event and credit/debits into their account /// based on the outcome. /// </summary> /// <param name="e">Event to be closed.</param> /// <param name="outcome">Outcome of the event.</param> public void CloseEvent(Event e, int outcome) { StringBuilder sb; Bet b; float losses, gains; float value; losses = gains = 0; List <int> punterBets = e.getBets(); foreach (int i in punterBets) { sb = new StringBuilder(); b = openBets[i]; Punter u = (Punter)users[b.getBetter()]; /* Set the Closed and Won Boolean values */ if (b.getOption() == outcome) { b.CloseBet(true); value = b.getCoins() * (float)b.getOdd(); u.CreditCoins(value); gains += value; } else { b.CloseBet(false); losses += b.getCoins(); } //PUNTER: Changes bet from open to closed u.CloseOpenBet(i); //System: Changes bet from open to closed openBets.Remove(i); closedBets.Add(i, b); //Notifications sb.Append(b.ToString()); u.PushNotification(sb.ToString()); } e.setGains(gains); e.setLosses(losses); e.CloseEvent(outcome); RemoveEvent(e); }
//Copy Constructor public Punter(Punter u) : base((User)u) { this.BetESSCoins = u.getBetESSCoins(); this.openBets = u.getOpenBets(); this.closedBets = u.getClosedBets(); }
/** ------------------- PUNTERS --------------------- **/ /// <summary> /// Adds a punter to the system. /// </summary> /// <param name="name">Punter's name.</param> /// <param name="email">Punter's e-mail.</param> /// <param name="pwd">Punter's password.</param> public void AddPunter(string name, string email, string pwd) { Punter p = new Punter(name, email, pwd, 0); users.Add(email, p); }