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 trialGyörgy Varga
19,198 PointsUser inputs tower details
Hi!
I've done that the user inputs the number of towers and the coordinates. I think it is working fine. Can you please check it? I would appreciate some feedback!
Thank you! :)
1 Answer
James Churchill
Treehouse TeacherGyörgy,
Nice job so far! But something looks amiss with your loop to populate the towers
array.
Tower[] towers = new Tower[numberOfTowers];
for(int i = 0; i<numberOfTowers; i++)
{
towers[i] = new Tower(new MapLocation(Coordinates[i], Coordinates[i+1], map));
}
The first time through the loop, i
would 0
and indexes into the Coordinates
array would be 0
and 1
. The second time through the loop, i
would 1
and indexes into the Coordinates
array would be 1
and 2
. Is that the behavior you were expecting?
Thanks ~James