コード例 #1
0
ファイル: Program.cs プロジェクト: K2329/Demo8
 static void Main(string[] args)
 {
     // luodaan olip Dice luokasta
     Dice dice = new Dice();
     int luku = dice.Heita(); // 1-6
     Console.WriteLine("Luku on {0}", luku);
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: FiraxisGlow/O-O-T
        static void Main(string[] args)
        {
           
            Dice dice = new Dice();
            int x;
            int y = 0;
            double avg;
            int[] numbers = new int[7];

            Console.WriteLine("How many times do you want to throw?");
            
            x = int.Parse(Console.ReadLine());


            //rollataan käyttäjän määrän mukaan
            for (int i = 0; i <= x; i++)
            {
                dice.Throw();
               
                //otetaan talteen numerot keskiarvoa varten
                y = (y + dice.rndnumb);
                numbers[dice.rndnumb]++;
            }
            avg = y / x; //keskiarvo

            for(int i = 1; i <= 6; i++)
            {
                Console.WriteLine( i + " occurred " + numbers[i] + "" );
            }

                Console.WriteLine("Avarage is: " + avg + "\nYou have rolled " + x + "times.");



        }
コード例 #3
0
ファイル: Program.cs プロジェクト: nikiliuhanen/demo08
 static void Main(string[] args)
 {
     Dice dice = new Dice();
     int number = dice.Throw(); // 1-6
     Console.WriteLine("How many times you want to throw the dice");
     int amount = int.Parse(Console.ReadLine());
     
     for (int i = 0; i < amount; i++)
     {
         number = dice.Throw();
         double average = number + amount;
         double ka = average / amount;
         
         Console.WriteLine("Dice is now thrown {0} times, number was {1} average is {2}", amount, number, ka);
     }
     number++;
     
 }