Solutions
Exercise 1
Tower mainTower = new(position: new Vector2(5, 5)); for (int level = 1; level <= mainTower.MaxLevel; level++) { double upgradeCost = 100 * Math.Pow(1.5, level - 1); Console.WriteLine($"Upgrading to level {level} costs {upgradeCost} gold"); if (playerGold >= upgradeCost) { mainTower.Upgrade(); playerGold -= upgradeCost; } }
Expressions:
new
Vector2(5, 5)
5 (x-coordinate)
5 (y-coordinate)
new(position: new
Vector2(5, 5))
1
level
mainTower.MaxLevel
level <=
mainTower.MaxLevel
level++
100
1.5
1
level - 1
Math.Pow(1.5, level...