Esempio n. 1
0
 public void ExchangeField(Player owner, Player buyer, IRentableField field)
 {
     if (Level > 0)
     {
         throw new InvalidOperationException("You have to sell all your houses before its possible to exchange with other players");
     }
     if (owner.Name == buyer.Name)
     {
         throw new ArgumentException("You can't Exchange with yourself");
     }
     if (field.Owner.Name != buyer.Name)
     {
         throw new ArgumentException("The Buyer has to own the " + field.Name);
     }
     if (owner.Name != this.Owner.Name)
     {
         throw new ArgumentException("The Player " + owner.Name + " does not own this field");
     }
     owner.AddToOwnerShip(field);
     buyer.RemoveFromOwnerShip(field);
     owner.RemoveFromOwnerShip(this);
     buyer.AddToOwnerShip(this);
     this.Owner = buyer;
     field.SetOwner(owner);
 }
 public void ExchangeField(Player owner, Player buyer, IRentableField field)
 {
     if (owner.Name == buyer.Name)
     {
         throw new ArgumentException("You can't Exchange with yourself");
     }
     if (field.Owner.Name != buyer.Name)
     {
         throw new ArgumentException("The Buyer has to own the " + field.Name);
     }
     if (owner.Name != this.Owner.Name)
     {
         throw new ArgumentException("The Player " + owner.Name + " does not own this field");
     }
     owner.AddToOwnerShip(field);
     buyer.RemoveFromOwnerShip(field);
     owner.RemoveFromOwnerShip(this);
     buyer.AddToOwnerShip(this);
     this.Owner = buyer;
     field.SetOwner(owner);
 }