RockPaperScissors

Hasaan Ausat's Pascal program converted to RemObjects C#

This conversion shows, for example:

You can save the file to a convenient directory as rps.cs, change the directory of the command prompt accordingly, then attempt to compile it with csc rps.cs. You will need to add the line using System; to the start of the file and change Integer to int throughout in order to compile it with Microsoft's C# compiler. It should then run by typing rps at the command prompt.

/* RockPaperScissors (Pascal Original) Copyright (c) 2010 Hasaan Ausat Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License, as described at http://www.apache.org/licenses/ and http://www.pp4s.co.uk/licenses/ Converted to Hydrogene (RemObjects C#) by Norman Morrison (2014) */ namespace rps { static class Program { public static void Main(string[] args) { Integer playcount, playercount, compcount, tiecount, number, answer; String choice = "y"; Console.WriteLine("|-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|"); Console.WriteLine("| |"); Console.WriteLine("| WELCOME TO ROCK PAPER SCISSORS |"); Console.WriteLine("| |"); Console.WriteLine("|*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-|"); Console.WriteLine(); Console.WriteLine("Press enter to continue"); Console.ReadLine(); playcount = 0; compcount = 0; playercount = 0; tiecount = 0; do { Console.WriteLine("Rock is 0, Paper is 1, Scissors is 2"); Console.WriteLine(); String input; input = Console.ReadLine(); Integer.TryParse(input, out number); if (number > 2) do { Console.WriteLine("Rock is 0, Paper is 1, Scissors is 2"); input = Console.ReadLine(); Integer.TryParse(input, out number); } while (number > 2); Random rnd = new Random(); answer = rnd.Next(0, 3); Console.WriteLine(); Console.WriteLine("I have picked " + answer.ToString()); Console.WriteLine(); if (answer == number) { Console.WriteLine("|-------|"); Console.WriteLine("| Tie!! |"); Console.WriteLine("|-------|"); Console.WriteLine(); playcount++; tiecount++; } else if ((answer == 0) && (number == 1)) { Console.WriteLine("|------------|"); Console.WriteLine("| You win :) |"); Console.WriteLine("|------------|"); Console.WriteLine(); playcount++; playercount++; } else if ((answer == 1) && (number == 0)) { Console.WriteLine("|--------------|"); Console.WriteLine("| You lose :( |"); Console.WriteLine("|--------------|"); Console.WriteLine(); playcount++; compcount++; } else if ((answer == 1) && (number == 2)) { Console.WriteLine("|------------|"); Console.WriteLine("| You win :) |"); Console.WriteLine("|------------|"); Console.WriteLine(); playercount++; playcount++; } else if ((answer == 2) && (number == 1)) { Console.WriteLine("|--------------|"); Console.WriteLine("| You lose :( |"); Console.WriteLine("|--------------|"); Console.WriteLine(); playcount++; compcount++; } else if ((answer == 2) && (number == 0)) { Console.WriteLine("|------------|"); Console.WriteLine("| You win :) |"); Console.WriteLine("|------------|"); Console.WriteLine(); playercount++; playcount++; } else if ((answer == 0) && (number == 2)) { Console.WriteLine("|--------------|"); Console.WriteLine("| You lose :( |"); Console.WriteLine("|--------------|"); Console.WriteLine(); playcount++; compcount++; } Console.WriteLine("Would you like to play again? y/n"); choice = Console.ReadLine(); Console.WriteLine(); } while (choice != "n"); Console.WriteLine("You have played " + playcount.ToString() + " times."); Console.WriteLine(); Console.WriteLine("You won " + playercount.ToString() + " times."); Console.WriteLine(); Console.WriteLine("You lost " + compcount.ToString() + " times."); Console.WriteLine(); Console.WriteLine("We drew " + tiecount.ToString() + " times."); Console.WriteLine(); Console.ReadLine(); if (compcount < playercount) { Console.WriteLine(" _"); Console.WriteLine(" ( (("); Console.WriteLine(" \\ =\\"); Console.WriteLine(" __\\_ `-\\"); Console.WriteLine("(____))( \\----"); Console.WriteLine("(____)) _"); Console.WriteLine("(____))"); Console.WriteLine("(____))____/----"); Console.WriteLine(); } if (compcount > playercount) { Console.WriteLine(" _____"); Console.WriteLine("((____ \\----"); Console.WriteLine("((____"); Console.WriteLine("((____"); Console.WriteLine("((____ ----"); Console.WriteLine(" / /"); Console.WriteLine(" (_(("); Console.WriteLine(); } if (compcount == playercount) { Console.WriteLine(" _"); Console.WriteLine(" ( (("); Console.WriteLine(" \\ =\\"); Console.WriteLine(" __\\_ `-\\"); Console.WriteLine("(____))( \\----"); Console.WriteLine("(____)) _"); Console.WriteLine("(____))"); Console.WriteLine("(____))____/----"); Console.WriteLine(" _____"); Console.WriteLine("((____ \\----"); Console.WriteLine("((____"); Console.WriteLine("((____"); Console.WriteLine("((____ ----"); Console.WriteLine(" / /"); Console.WriteLine(" / =/"); Console.WriteLine(" (_(("); Console.WriteLine(); } Console.WriteLine("Goodbye, Hope you had fun!!!!!!!!!"); Console.WriteLine(); Console.ReadLine(); Console.WriteLine("RockPaperScissors (c) 2009 - Huskimo"); Console.ReadLine(); } } }