hey ppl, could anyone help me out, ive written a c# app, but i need it compiled, its just a little simple program for one of my first programming assignments at university, i dont have c# on my computer though.
ive gone over and over this program, i do not believe there to be any errors, or if there is, they should be minor, so if someone could compile and post it up for me, that would be great, thanks.
/* Keiran Jones
* 100024606
* Software Development 1
* Wayne Rippin
*/
using System;
namespace DropDead.cs
{
class Program
{
static void Main(string[] args)
{
//here i have declaired my variables and random number gen, i have set the default value to 0
int NumberOfDice=0;
int ThrowTotal = 0;
int RoundTotal=0;
int DeadDice=0;
int iResult = 0;
string Answer="";
Random numgen = new Random();
//this is just a little welcome message and some space
Console.WriteLine("Welcome to Drop Dead.");
Console.WriteLine(); Console.WriteLine();
//asking the user how many dice, the do-while loop will continue until a valid answer is given
Console.WriteLine("Please select how many dice you would like to play with.");
do
{
//remind user of range
Console.WriteLine("Select between 1 and 10");
//get answer
Answer = Console.ReadLine();
//if the answer is an integar
if (Int32.TryParse(Answer, out iResult))
{
//set that value
NumberOfDice=Int32.Parse(Answer);
}
//if it is in the range 1-10, use it
} while (NumberOfDice > 10 || NumberOfDice < 1);
//define my array with the required number of fileds
int[] DiceThrows = new int[NumberOfDice];
//more space
Console.WriteLine(); Console.WriteLine();
//the games main loop
do
{
//reset my variables and array
RoundTotal = 0;
ThrowTotal = 0;
DeadDice = 0;
//run through array setting values to 1
for (int i = 0; i < NumberOfDice; i++)
{ DiceThrows[i] = 1; }
//the automated game loop
do
{
//write out information
Console.Write("The dice rolls are: ");
//for the number of dice....
for (int i = 0; i < NumberOfDice; i++)
{
//if dice is alive
if (DiceThrows[i] > 0)
{
//get a random value and apply
DiceThrows[i] = numgen.Next(1, 7);
//display result
Console.Write(DiceThrows[i] + " | ");
}
}
//new line
Console.WriteLine();
//the for loop that checks for the dead dice, and adds the score
for (int i = 0; i < NumberOfDice; i++)
{
//if dice is equal to 2 or 5
if (DiceThrows[i] == 2 || DiceThrows[i] == 5)
{
//kill that dice and increment the dead dice total
DiceThrows[i] = 0;
DeadDice++;
}
else
{
//else add the value to the throws total
ThrowTotal += DiceThrows[i];
}
}
//display the throws stats, add the knew round total, and clear the throw total.
Console.WriteLine("This throws total is " + ThrowTotal + " With " + DeadDice + " dead dice.");
RoundTotal += ThrowTotal;
ThrowTotal = 0;
//while there are dice left
} while (DeadDice < NumberOfDice);
//else display the final score, and ask the user if they would like to play again
Console.WriteLine("Your final score is " + RoundTotal);
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Do you want to play again? Y/N");
Answer=Console.ReadLine();
}
// if the user presses 'y' then they play again
while (Answer == "Y" || Answer =="y");
}
}
}
P.s. sorry if this is wrong forum, i just figured it get a quicker response here...