Advertisement
6677

Dragon Realms

Oct 13th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace DragonRealm
  6. {
  7.     class Program
  8.     {
  9.         static void displayIntro()
  10.         {
  11.             Console.WriteLine("You are in a land full of dragons. In front of you,");
  12.             Console.WriteLine("you see two caves. In one cave, the dragon is friendly");
  13.             Console.WriteLine("and will share his treasure with you. The other dragon");
  14.             Console.WriteLine("is greedy and hungry, and will eat you on sight.");
  15.             Console.WriteLine();
  16.         }
  17.  
  18.         static string chooseCave()
  19.         {
  20.             string cave = "";
  21.             while ((cave != "1") & (cave != "2"))
  22.             {
  23.                 Console.WriteLine("Which cave will you go into? (1 or 2)");
  24.                 cave = Console.ReadLine();
  25.             }
  26.             return cave;
  27.         }
  28.  
  29.         static void checkCave(string chosenCave)
  30.         {
  31.             Console.WriteLine("You approach the cave...");
  32.             Console.WriteLine("");
  33.             System.Threading.Thread.Sleep(800);
  34.             Console.WriteLine("It is dark and spooky...");
  35.             Console.WriteLine("");
  36.             System.Threading.Thread.Sleep(800);
  37.             Console.WriteLine("A large dragon jumps out infront of you! He opens his jaws and...");
  38.             Console.WriteLine("");
  39.             System.Threading.Thread.Sleep(1200);
  40.  
  41.             Random random = new Random();
  42.             string friendlyCave = random.Next(1, 3).ToString();
  43.  
  44.             if (chosenCave == friendlyCave)
  45.             {
  46.                 Console.WriteLine("Gives you his treasure!");
  47.             }
  48.             else
  49.             {
  50.                 Console.WriteLine("Gobbles you down in one bite!");
  51.             }
  52.         }
  53.  
  54.         static void Main(string[] args)
  55.         {
  56.             string playAgain = "yes";
  57.             while (playAgain == "yes")
  58.             {
  59.                 Console.Clear();
  60.                 displayIntro();
  61.                 string CaveNumber = chooseCave();
  62.                 checkCave(CaveNumber);
  63.  
  64.                 Console.WriteLine("Do you want to play again? (yes or no)");
  65.  
  66.                 playAgain = Console.ReadLine();
  67.             }
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement