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#

About adding coordinates to the Tower

Hi steven :D, i opened a new discussion.

i saw ur last answer, what do u mean by argument?, i added a MapLocation object to each of them, beside Tower.cs in the decreasHealth method.

current snapshot: https://w.trhou.se/thdrmqefke

Steven Parker

3 Answers

Steven Parker
Steven Parker
215,939 Points

The "arguments" are the values you pass in the parentheses when you make a call to a method.

So here's your definition of "decreaseHealth" on line 109 of Invader.cs:

        public virtual void decreaseHealth(int factor, MapLocation towerLocation)

It now requires two arguments, an int and a MapLocation.

But here on line 52 of Tower.cs it is being called but given only one argument:

            invader.decreaseHealth(towerPower);

Whenever you change a method signature (which means the number and/or type of arguments), you have to also change every place it is called in the code to match. So the call in Tower.cs needs to pass along the MapLocation now:

            invader.decreaseHealth(towerPower, _location);  // pass tower location also!

And the same issue applies in the two other places it gets called.

i deleted my tries, this is the current snap: https://w.trhou.se/suzjr3k4f6

Steven Parker where i pass the arguments?

Thanks steven now its working and i learned from that! this is the current snap: https://w.trhou.se/othrwt3nt7

I just cant figure out how to deal with the duplicate message at sniperTower

Steven Parker

Steven Parker
Steven Parker
215,939 Points

<noob /> — I think that question has been taken up separately. If this one has been answered, you can mark it solved by choosing a "best answer".
And happy coding!