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 trialBrandon Mendez
4,177 PointsI keep receiving a CS0103 error and a CS1061 error?
I tried compiling my code and I managed to knock down the compiler errors by half. I keep receiving these errors.
Invader.cs(9,42): error CS1061: Type TreehouseDefense.Path' does not contain a definition for
GetLocationAt' and no extension method GetLocationAt' of type
TreehouseD
efense.Path' could be found. Are you missing an assembly reference?
Path.cs(3,11): (Location of the symbol related to previous error)
Level.cs(12,7): error CS0103: The name _invaders' does not exist in the current context
Level.cs(17,31): error CS0103: The name
_invaders' does not exist in the current context
Level.cs(23,32): error CS0103: The name _invaders' does not exist in the current context
Level.cs(27,36): error CS0103: The name
_invaders' does not exist in the current context
Compilation failed: 5 error(s), 1 warnings
using System; namespace TreehouseDefense { class Invader { private readonly Path _path; private int _pathStep = 0;
public MapLocation Location => _path.GetLocationAt(_pathStep);
public bool HasScored { get { return _pathStep >= _path.Length; } }
public int Health {get; private set; } = 2;
public bool IsNeutralized => Health <= 0;
public bool IsActive => !(IsNeutralized || HasScored);
public Invader(Path path) //Constructor
{
_path = path;
}
//ex. single line method
public void Move() => _pathStep +=1;
public virtual void DecreaseHealth(int factor) //virtual meaning
{
Health -= factor;
System.Console.WriteLine("Shot at and hit an invader!");
}
} }
https://teamtreehouse.com/workspaces/40952082# Here is my workspace.