Advertisement
Guest User

Untitled

a guest
May 26th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.88 KB | None | 0 0
  1. using System;
  2. using TerminalUserInput;
  3. using SwinGame;
  4.  
  5. namespace HighestScore
  6. {
  7.     class GameScoreData
  8.     {   public  enum DifficultyKind {normal, hard, insane};
  9.         public string User{get; set;}
  10.         public int Score{get;set;}
  11.         public int GameID{get; set;}
  12.         public DifficultyKind Difficulty{get; set;}
  13.     }
  14.  
  15.     class Highscores
  16.     {
  17.         public static Scores ReadDifficulty(string prompt)
  18.         {
  19.             Difficulty DifficultyKind;
  20.             bool Valid = False;
  21.             Difficulty = ReadString("Enter Difficulty");
  22.             while (Valid == False)
  23.             {
  24.                 if (Difficulty.ToLower() = "insane")
  25.                 {
  26.                     Valid == True;
  27.                 }
  28.                 if (Difficulty.ToLower() = "hard")
  29.                 {
  30.                     Valid == True;
  31.                 }
  32.                 if (Difficulty.ToLower()= "normal")
  33.                 {
  34.                     Valid == True;
  35.                 }
  36.                 else
  37.                 {
  38.                     Difficulty == ReadString("Enter Difficulty - ");
  39.                 }
  40.             }
  41.         }
  42.         public static Scores ReadScores(string prompt)
  43.         {
  44.             result = 0;
  45.             result = ReadInteger("Enter Score: ");
  46.             do
  47.             {
  48.                
  49.                 if (result < 0)
  50.                 {
  51.                 result = ReadInteger("You must enter a positive value: ");
  52.                 }
  53.             } while (result < 0);
  54.             return result;
  55.         }
  56.  
  57.         public static Scores AddScore()
  58.         {
  59.             Scores result = new Scores();
  60.             Console.WriteLine(prompt);
  61.             result.GameID = Input.ReadInteger("Enter GameID: ");
  62.             result.User = Input.ReadString("Enter Name: ");
  63.             result.Score = ReadScores();
  64.             result.DifficultyKind = ReadDifficulty();
  65.         }  
  66.  
  67.         public static Scores PrintScoreData()
  68.         {  
  69.             foreach (var GameScoreData in Scores)
  70.             {
  71.                 Console.WriteLine("User name: - {0} | Score: - {1} | Game Id - {2} | Difficulty - {3}", Scores.User, Scores.Score, Scores.GameID, Scores.Difficulty );
  72.                 if (Scores.Score < 1000)
  73.                 {
  74.                     Console.WriteLine("Newb!");
  75.                 }
  76.                 if (Scores.Score > 100000)
  77.                 {
  78.                     Console.WriteLine("Godlike!");
  79.                 }
  80.             }
  81.         }
  82.  
  83.         public static void main ()
  84.         {   string name;
  85.             int numScores;
  86.             int menuNavigation = 0;
  87.             List<GameScoreData> Scores = new List<GameScoreData>();
  88.             numscores = ReadInteger("Enter intial number of scores - ");
  89.             SetLength(Scores, numScores);
  90.             Scores = WriteScores(Scores);
  91.             do
  92.             {
  93.                     Console.WriteLine("1: Add another score");
  94.                     Console.WriteLine("2: Print all scores");
  95.                     Console.WriteLine("3:Find the highest score");
  96.                     Console.WriteLine("4 Quit");
  97.                     menuNavigation = ReadInteger("Enter your selection - ");
  98.                 switch (menuNavigation)
  99.                 {
  100.                     case 1:
  101.                         Scores.Add(Scores);
  102.                         break;
  103.                     case 2:
  104.                         ReadScores(Scores);
  105.                         break;
  106.                     case 3:
  107.                         name = ReadString("Enter a name to find the highest score - ");
  108.                         Console.Writeline("The highest score for ", name, " is ", HighestScore(Scores, name));
  109.                         break;
  110.                     case 4:
  111.                         exit;
  112.                         break;
  113.                     default:
  114.                         Console.WriteLine("Enter a number from 1 to 4: ");
  115.                         break;
  116.                 }
  117.                    
  118.             }while ( menuNavigation != 4); 
  119.         }
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement