• 0

C# Help - Program not working..


Question

Hey all

Im creating a random number generator to simulate the rolling of three dice. I've put together code (not sure how correct it is) and for some reason instead of displaying random numbers between 1 and 7 it just displays 0's. Can anyone help me to fix this problem?

Thanks

Heres the code

using System;
using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1
{

	class Program
	{
		static void Main(string[] args)
		{

			RollingDice rd = new RollingDice();
			Console.WriteLine("Rolling count:{0}", rd.rollingCount);
			Console.Write(rd.first);
			Console.Write(rd.second);
			Console.Write(rd.third);
			Console.ReadKey();
		}


	}
	class RollingDice
	{
		public int first;
		public int second;
		public int third;
		public int rollingCount;
		Random r = new Random();

		public void CallBackFunction(Object stateInfo)
		{

			first = r.Next(1,7);
			second = r.Next(1,7);
			third = r.Next(1,7);
			Console.Write(first);
			Console.Write(second);
			Console.Write(third);
			Console.Write("\b\b\b");
			rollingCount++;

			if (first == second || first == third || second == third)
			{
				Console.Write("you scored:");

			}

			if (CheckIfExistTwoNumberEqual())
			{

			}

		}
		bool CheckIfExistTwoNumberEqual()
		{
			return (first == second || first == third || second == third);
		}
	}


}

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
Is this homework, or did you leave the spots where the code that would make it work goes blank on purpose? ;)

I wasn't sure how to make it work from here, i didn't purposely leave places blank..

It was a question i was given to work on to help our understand of C#. I've done this so far but don't know what to do next, would you be able to help?

Cheers

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.