3 Replies - 918 Views - Last Post: 25 May 2010 - 05:37 AM Rate Topic: -----

#1 Geckko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-May 10

Twenty-Six Dice Game

Posted 24 May 2010 - 08:53 PM

Play: The player chooses a number from 1 to 6 as his point number and places a bet. He then throws 10 dice 13 times. His score is the number of times that his point number is thrown and pay-off is based on the odds given.

Ok...I have a GREAT start to this program. I have a nice 'welcome' message explaining the rules of the game and giving the odds. The program then requests that the player to enter their point number and place their bet; the program then rolls the dice, displays the results of each roll and the total number each die was rolled.

And this is where I am stuck. The Player's 'point' has to be equal to 10 or less, 13, 26, 27, 28, 29 or 30 or more in order to 'win'. Then I need to multiply their 'bet' by the 'pay off".

This is what I have so far:

public class TwentySix
    {
        public static void Main(string[] args)
        {
            #region Opening Message
            Console.WriteLine("Welcome to Twenty-Six!");
            Console.WriteLine("");
            Console.WriteLine("The rules are simple:");
            Console.WriteLine("");
            Console.WriteLine("A player chooses a number from 1 to 6 as his point number and places a");
            Console.WriteLine("bet based on the total number of times he think his point number will");
            Console.WriteLine("show up after rolling 10 dice, 13 times.");
            Console.WriteLine("");
            Console.WriteLine("Pay-Off Odds:");
            Console.WriteLine("");
            Console.WriteLine("10 or less:\t10 to 1");
            Console.WriteLine("13:\t\t 5 to 1");
            Console.WriteLine("26:\t\t 4 to 1");
            Console.WriteLine("27:\t\t 5 to 1");
            Console.WriteLine("28:\t\t 6 to 1");
            Console.WriteLine("29:\t\t 8 to 1");
            Console.WriteLine("30 or more:\t10 to 1");
            Console.WriteLine("Any other score loses.");
            Console.WriteLine("");

            Console.Write("Please select a number between 1 and 6 and press 'Enter': ");
            int point = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Thank you.  Your Point is {0}", point);
            Console.WriteLine("");
            Console.Write("Please place your bet, whole dollars only, and press 'Enter': ");
            int bet = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Thank you.  Your bet is {0:C}", bet);
            Console.WriteLine("");
            Console.WriteLine("Good luck!");
            Console.WriteLine("");
            Console.WriteLine("Your rolls:");
            
            //Console.Read();
            #endregion

            #region GameSetUp
            Random randomNumbers = new Random();

            int die1 = 0;
            int die2 = 0;
            int die3 = 0;
            int die4 = 0;
            int die5 = 0;
            int die6 = 0;

            int face;

            // rolls the dice and displays result of each roll
            for (int roll = 1; roll <= 130; roll++)
            {
                face = randomNumbers.Next(1, 7);

                Console.Write("{0} ", face);

                if (roll % 10 == 0)
                    Console.WriteLine();

                // tracks how often each die is rolled and displays results
                switch (face)
                {
                    case 1:
                        ++die1;
                        break;
                    case 2:
                        ++die2;
                        break;
                    case 3:
                        ++die3;
                        break;
                    case 4:
                        ++die4;
                        break;
                    case 5:
                        ++die5;
                        break;
                    case 6:
                        ++die6;
                        break;
                }
            }
            Console.WriteLine("");
            Console.WriteLine("Die\t Rolled");
            Console.WriteLine("1\t{0}\n2\t{1}\n3\t{2}\n4\t{3}\n5\t{4}\n6\t{5}",
                die1, die2, die3, die4, die5, die6);
            Console.WriteLine("");
            #endregion

            #region Payoff
            

            

            #endregion


            #region Determination
            if ((point == die1) && (die1 <= 10))
                Console.WriteLine("You won {0:C}!", total);
            else
                Console.WriteLine("Sorry, you lose.");

            #endregion

            Console.WriteLine("Thank you for playing Twenty-Six!");
            Console.Read();
        }
    }


Is This A Good Question/Topic? 0
  • +

Replies To: Twenty-Six Dice Game

#2 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 527
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Twenty-Six Dice Game

Posted 24 May 2010 - 08:57 PM

Do you know what a method is?

Your first step is to actually break these steps up into methods.
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Twenty-Six Dice Game

Posted 25 May 2010 - 04:53 AM

Here's a start: Create a method to roll a Die class and return the rolled number.
Was This Post Helpful? 0
  • +
  • -

#4 Shivern  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 27
  • Joined: 20-May 10

Re: Twenty-Six Dice Game

Posted 25 May 2010 - 05:37 AM

why did you put it all in one method again?
You had a good class on your last project, why not keep that?

~Shivern
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1