static void Main(string[] args) { // in a .NET program, paths will be relative to the location of the application dll (usually down in bin/debug/etc) string filePath = "../../../data.json"; // should be next to this file var persistence = new JsonFilePersistence(filePath); var game = new GameLogic(persistence); // Loops game until user quits while (true) { var input = ""; while (!ValidInput(input)) // Read user input until a valid entry is received { Console.WriteLine("Enter your choice (\"Rock\", \"Paper\", or \"Scissors\") [Q] to quit:"); input = Console.ReadLine(); } if (input.Equals("q", StringComparison.OrdinalIgnoreCase)) // quit game if user entered Q { Console.WriteLine("Exiting Game."); persistence.Write(game.Scores); return; } else // otherwise assign player an element object { game.PlayerElement = ReadPlayerChoice(input); } // print outcome and scoreboard Console.WriteLine(game.result()); Console.Write($"\nScore:\nYou: {game.Scores.PlayerScore}\nAI: {game.Scores.AIScore}\nDraws: {game.Scores.Draws}\n\n"); } }
public GameLogic(JsonFilePersistence persistence) { Scores = persistence.Read(); }