Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Loops and Final Touches Playing the Game

Tyler Marquer
Tyler Marquer
12,859 Points

I got an error i cant figure out how to fix

All of my code: https://w.trhou.se/jl2zxgzkav

Gives these errors and warnings:

Game.cs(35,21): error CS1729: The type TreehouseDefense.Tower' does not contain a constructor that takes1' arguments
Tower.cs(10,16): (Location of the symbol related to previous error)
Game.cs(36,21): error CS1729: The type TreehouseDefense.Tower' does not contain a constructor that takes1' arguments
Tower.cs(10,16): (Location of the symbol related to previous error)
Game.cs(37,21): error CS1729: The type TreehouseDefense.Tower' does not contain a constructor that takes1' arguments
Tower.cs(10,16): (Location of the symbol related to previous error)
Compilation failed: 3 error(s), 0 warnings

2 Answers

Hi Tyler Marquer,

The constructor method in Tower class is expecting two parameters(mapLocation, path).But, In the Game.cs you are calling the constructor with only one parameter as shown in below Tower[] towers = { new Tower(new MapLocation(1, 3, map)), new Tower(new MapLocation(3, 3, map)), new Tower(new MapLocation(5, 3, map)) }; pass the path parameter also to get rid of this error. Hope it helps.

Tyler Marquer
Tyler Marquer
12,859 Points

I have tried a few things but nothing seems to fix it