Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Tyler Marquer
Tyler Marquer
4,091 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

Monika Polishetty
Monika Polishetty
5,639 Points

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
4,091 Points

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