This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Game.cs

By: a guest on Jul 28th, 2010  |  syntax: C#  |  size: 1.68 KB  |  views: 66  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace ConsoleMenu
  5. {
  6.     class Game
  7.     {
  8.         private Menu gameMenu;
  9.         private string[] menuOptions = new string[] { "Play", "Credits", "Exit" };
  10.  
  11.         public Game()
  12.         {
  13.             gameMenu = new Menu();
  14.         }
  15.  
  16.         public void Begin()
  17.         {
  18.             string selectedOption;
  19.             do
  20.             {
  21.                 selectedOption = gameMenu.ShowMenu();
  22.                 if (selectedOption == menuOptions[0])
  23.                     Play();
  24.                 else if (selectedOption == menuOptions[2])
  25.                     Exit();
  26.                 else
  27.                     ShowCredits();
  28.             } while (selectedOption == menuOptions[1]);
  29.         }
  30.  
  31.         private void ShowCredits()
  32.         {
  33.             Console.Clear();
  34.             Console.WriteLine("Written By: insertAlias");
  35.             Thread.Sleep(500);
  36.             Console.WriteLine("Directed By: insertAlias");
  37.             Thread.Sleep(500);
  38.             Console.WriteLine("Produced By: insertAlias");
  39.             Thread.Sleep(500);
  40.             Console.WriteLine("Played By: You!");
  41.             Thread.Sleep(500);
  42.             Console.WriteLine("Press any key to return to the menu.");
  43.             Console.ReadKey();
  44.         }
  45.  
  46.         private void Play()
  47.         {
  48.             Console.Clear();
  49.             Console.WriteLine("Beginning Game...");
  50.             Thread.Sleep(500);
  51.             Console.WriteLine("Playing Game...");
  52.             Thread.Sleep(500);
  53.             Console.WriteLine("Exiting Game...");
  54.         }
  55.  
  56.         private void Exit()
  57.         {
  58.             Console.Clear();
  59.             Console.WriteLine("Exiting Game...");
  60.             Thread.Sleep(500);
  61.         }
  62.     }
  63. }
clone this paste RAW Paste Data