Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace LeftRightCenter
- {
- class Player
- {
- //fields
- private int _quarters = 4;
- private string _name = "";
- public int Quarters {
- get{ return _quarters; }
- set{ _quarters += value; }
- }
- public string Name{ get { return _name;}}
- public Player(string name)
- {
- _name = name;
- }
- }
- class Dice
- {
- Random _random = new Random ();
- public int Roll ()
- {
- int diceSide;
- diceSide = _random.Next (0, 6);
- diceSide = (diceSide > 2) ? 3 : diceSide;
- return diceSide;
- }
- public Dice ()
- {
- }
- }
- class MainClass
- {
- static int activePlayer = 0;
- static int theCup = 0;
- static Player[] thePlayers = {
- new Player ("Jessica"),
- new Player ("Isaac"),
- new Player ("Ed"),
- new Player ("Bella"),
- new Player ("Elisa"),
- new Player ("Fake RedHead"),
- new Player ("Linda"),
- new Player ("MJ"),
- new Player ("Irene"),
- new Player("Devin")
- };
- static Dice[] theDice = new Dice[3]{new Dice(), new Dice(), new Dice()};
- private static void MoveQuarter (int direction)
- {
- int numberOfPlayers = thePlayers.Length - 1;
- switch (direction) {
- case 0:
- Console.WriteLine (thePlayers [activePlayer].Name + " Rolls Center");
- thePlayers [activePlayer].Quarters = -1;
- theCup++;
- break;
- case 1:
- Console.WriteLine (thePlayers [activePlayer].Name + " Rolls Left");
- thePlayers [activePlayer].Quarters = -1;
- int leftPlayer = (activePlayer == 0) ? numberOfPlayers : activePlayer - 1;
- thePlayers [leftPlayer].Quarters = +1;
- break;
- case 2:
- Console.WriteLine (thePlayers [activePlayer].Name + " Rolls Right");
- thePlayers [activePlayer].Quarters = -1;
- int rightPlayer = (activePlayer == numberOfPlayers) ? 0 : activePlayer + 1;
- thePlayers [rightPlayer].Quarters = +1;
- break;
- default:
- Console.WriteLine (thePlayers [activePlayer].Name + " Rolls Dot");
- break;
- }
- }
- public static void Main (string[] args)
- {
- int cupEndPoint = thePlayers.Length * 4 - 1;
- while (theCup < cupEndPoint) {
- activePlayer = (activePlayer < thePlayers.Length - 1) ? activePlayer + 1 : 0;
- if (thePlayers [activePlayer].Quarters == 0) {
- continue;
- }
- foreach (Dice rattle in theDice) {
- if (thePlayers [activePlayer].Quarters > 0 && theCup < cupEndPoint) {
- MoveQuarter (rattle.Roll ());
- }
- }
- Console.WriteLine (
- thePlayers [activePlayer].Name + " now has {0} Quarters and there are {1} Quarters In the Cup",
- thePlayers [activePlayer].Quarters,
- theCup
- );
- }
- foreach (Player player in thePlayers) {
- if (player.Quarters == 1) {
- Console.WriteLine (player.Name + " WINS! and recieves {0} QUARTERS!", theCup + 1);
- } else {
- continue;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment