/// <see cref="IPlayer.DevelopProperty"/> public void DevelopProperty(DevelopableLand property) { if (propertiesOwned.Contains(property)) { int developCost = property.GetDevelopCost(); if (developCost <= cash) { try // attempt to develop property and propagate errors to front end { property.Develop(); cash = cash - developCost; } catch (DevelopableLandException e) { throw new HumanPlayerException(e.Message); } } else { throw new DevelopableLandException("Player doesn't have enough cash to develop the property!"); } } else { throw new DevelopableLandException("Cannot develop a property that you don't own!"); } }
/// <see cref="IPlayer.UndevelopProperty"/> public void UndevelopProperty(DevelopableLand property) { // check if player owns this property if (propertiesOwned.Contains(property)) { int developCost = property.GetDevelopCost(); try // attempt to undevelop and propagate errors to front end { property.Undevelop(); cash = cash + developCost; } catch (DevelopableLandException e) { throw new HumanPlayerException(e.Message); } } else { throw new HumanPlayerException("Cannot undevelop a property that you don't own!"); } }