Last active
October 25, 2017 16:39
-
-
Save janellbaxter/426ebbb094e6b15ea9df8d76bcc113ef to your computer and use it in GitHub Desktop.
8.1 Branching Framework; Programming is Fun: C# Adventure Game (Learn C#)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 8.1 Branching Framework | |
* Example code from Programming is Fun: C# Adventure Game | |
* Learn C# (for beginners) | |
* http://programmingisfun.com/learn/c-sharp-adventure-game | |
*/ | |
using System; | |
namespace Adventure | |
{ | |
public static class Game | |
{ | |
static string CharacterName; | |
public static void StartGame() | |
{ | |
Console.WriteLine("Game Title"); | |
Console.WriteLine("Welcome to ..."); | |
NameCharacter(); | |
Choice(); | |
} | |
static void Choice() | |
{ | |
string input = ""; | |
Console.WriteLine(CharacterName + " which path will you choose? A or B?"); | |
input = Console.ReadLine(); | |
if (input.ToLower() == "a") | |
{ | |
Console.WriteLine("You've chosen path A!"); | |
} | |
else | |
{ | |
Console.WriteLine("You've chosen path B!"); | |
} | |
} | |
static void NameCharacter() | |
{ | |
Console.WriteLine("What would you like your character's name to be?"); | |
CharacterName = Console.ReadLine(); | |
Console.WriteLine("Great! Your character is now named " + CharacterName); | |
} | |
} | |
class Item | |
{ | |
} | |
class Program | |
{ | |
static void Main() | |
{ | |
Game.StartGame(); | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Double check this section, I was hanging up here by not going back up and inserting the Choice();
public static void StartGame()
{
Console.WriteLine("Game Title");
Console.WriteLine("Welcome to ...");
NameCharacter();
Choice();
}