Learn
Before we get into ASP.NET, let’s take a look at a basic dependency in C#.
In this program we have two important classes:
Trainer
LoudSpeaker
In order to work correctly, the Trainer
class needs a LoudSpeaker
instance. Thus LoudSpeaker
will be a dependency for the Trainer
class.
Instructions
1.
In Trainer.cs, in the Trainer
constructor, instantiate a LoudSpeaker
object and store it in the speaker
field.
You instantiate LoudSpeaker
with the parameterless constructor:
new LoudSpeaker()
2.
In the body of Trainer.BeginTraining()
, use the speaker
by adding this line:
speaker.Amplify("Time to sweat");
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.