Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using TerminalUserInput;
- using SwinGame;
- namespace HighestScore
- {
- class GameScoreData
- { public enum DifficultyKind {normal, hard, insane};
- public string User{get; set;}
- public int Score{get;set;}
- public int GameID{get; set;}
- public DifficultyKind Difficulty{get; set;}
- }
- class Highscores
- {
- public static Scores ReadDifficulty(string prompt)
- {
- Difficulty DifficultyKind;
- bool Valid = False;
- Difficulty = ReadString("Enter Difficulty");
- while (Valid == False)
- {
- if (Difficulty.ToLower() = "insane")
- {
- Valid == True;
- }
- if (Difficulty.ToLower() = "hard")
- {
- Valid == True;
- }
- if (Difficulty.ToLower()= "normal")
- {
- Valid == True;
- }
- else
- {
- Difficulty == ReadString("Enter Difficulty - ");
- }
- }
- }
- public static Scores ReadScores(string prompt)
- {
- result = 0;
- result = ReadInteger("Enter Score: ");
- do
- {
- if (result < 0)
- {
- result = ReadInteger("You must enter a positive value: ");
- }
- } while (result < 0);
- return result;
- }
- public static Scores AddScore()
- {
- Scores result = new Scores();
- Console.WriteLine(prompt);
- result.GameID = Input.ReadInteger("Enter GameID: ");
- result.User = Input.ReadString("Enter Name: ");
- result.Score = ReadScores();
- result.DifficultyKind = ReadDifficulty();
- }
- public static Scores PrintScoreData()
- {
- foreach (var GameScoreData in Scores)
- {
- Console.WriteLine("User name: - {0} | Score: - {1} | Game Id - {2} | Difficulty - {3}", Scores.User, Scores.Score, Scores.GameID, Scores.Difficulty );
- if (Scores.Score < 1000)
- {
- Console.WriteLine("Newb!");
- }
- if (Scores.Score > 100000)
- {
- Console.WriteLine("Godlike!");
- }
- }
- }
- public static void main ()
- { string name;
- int numScores;
- int menuNavigation = 0;
- List<GameScoreData> Scores = new List<GameScoreData>();
- numscores = ReadInteger("Enter intial number of scores - ");
- SetLength(Scores, numScores);
- Scores = WriteScores(Scores);
- do
- {
- Console.WriteLine("1: Add another score");
- Console.WriteLine("2: Print all scores");
- Console.WriteLine("3:Find the highest score");
- Console.WriteLine("4 Quit");
- menuNavigation = ReadInteger("Enter your selection - ");
- switch (menuNavigation)
- {
- case 1:
- Scores.Add(Scores);
- break;
- case 2:
- ReadScores(Scores);
- break;
- case 3:
- name = ReadString("Enter a name to find the highest score - ");
- Console.Writeline("The highest score for ", name, " is ", HighestScore(Scores, name));
- break;
- case 4:
- exit;
- break;
- default:
- Console.WriteLine("Enter a number from 1 to 4: ");
- break;
- }
- }while ( menuNavigation != 4);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement