Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Reka
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] playerOneEntries = new int[7];
  14.             int[] playerTwoEntries = new int[7];
  15.             string result = "";
  16.             bool playerTwoFailsOnce = false;
  17.  
  18.             Console.WriteLine("Player one please enter 7 values: ");
  19.             for(int i = 0; i <7; i++)
  20.             {
  21.                 Console.Write(string.Format("Enter number {0} > ", i+1));
  22.                 playerOneEntries[i] = (Convert.ToInt16(Console.ReadLine()));
  23.             }
  24.  
  25.             Console.Clear();
  26.  
  27.             for (int i = 0; i < 6; i++)
  28.             {
  29.                 Console.Write(string.Format("{0} value is {1} ", (i > 0 ? "the next" : "Player 2 the first"),  playerOneEntries[i] ));
  30.                 Console.WriteLine();
  31.                 Console.Write("Higher (H) or lower (L) > ");
  32.                 result = Console.ReadKey().Key.ToString().ToUpper();
  33.                 Console.WriteLine();
  34.                 if (result == "H")
  35.                 {
  36.                     if(playerOneEntries[i+1] > playerOneEntries[i])
  37.                     {
  38.                         Console.Write("Correct, ");
  39.                     }else
  40.                     {
  41.                         playerTwoFailsOnce = true;
  42.                         Console.Write("Incorrect, ");
  43.                     }
  44.                 }
  45.                 else if(result == "L")
  46.                 {
  47.                     if (playerOneEntries[i + 1] < playerOneEntries[i])
  48.                     {
  49.                         Console.Write("Correct, ");
  50.                     }
  51.                     else
  52.                     {
  53.                         playerTwoFailsOnce = true;
  54.                         Console.Write("Incorrect, ");
  55.  
  56.                     }
  57.                 }
  58.                 else
  59.                 {
  60.                     Console.WriteLine("Invalid answer..");
  61.                 }
  62.  
  63.  
  64.             }
  65.  
  66.             Console.WriteLine();
  67.             Console.WriteLine();
  68.  
  69.             if (playerTwoFailsOnce)
  70.             {
  71.                 Console.WriteLine("Incorrect, sorry player 1 wins");
  72.             }
  73.             else
  74.             {
  75.                 Console.WriteLine("Player 2 wins");
  76.             }
  77.             Console.Read();
  78.  
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement