2.2 Import External Scripts

In the last section, you’ve used a function to print a message in the console:

💻 C#

Console.WriteLine("Welcome to Odds and Evens!");

The function has a parameter so it can receive different messages.

🎓 Learn


In a console game, all messages are text, so let’s make them look nicer than the default ones.

We’ve prepared a few scripts with extra functions to help with this - GameUtilities.

Reusing code is a common practice in programming. Instead of building from scratch, we reuse existing functions that fulfill our needs.

To use the new functions, you need to copy the scripts into the project.

🎓 Learn


What to Do

🎯 Expected Outcome

You should have the following inside Visual Studio Code:

odds-and-evens
    GameUtilities
        GameInput.cs
        GamePrint.cs
        GameRandom.cs
    csharp.csproj
    Program.cs