using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exampleChess
{
class Program
{
static void Main(string[] args)
{
Random random1 = new Random();
for (int i = 0; i < 3; i++)
{
enum color { black, white};
enum chess { pawn, knight, bishop, rook, king, queen};
color colors = random1.Next(0, 2);
chess pieces = random1.Next(0, 6);
Console.WriteLine(colors + " " + pieces);
}
}
}}
Hirendra SisodiyaPosted Mar 25, 2010, 1:44 AM
wim haesPosted Mar 24, 2010, 6:47 PM
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exampleChess
{
enum color { black, white};
enum chess { pawn, knight, bishop, rook, king, queen};
class Program
{
static void Main(string[] args)
{
Random random1 = new Random();
for (int i = 0; i < 3; i++)
{
color colors = (color) random1.Next(0, 2);
chess pieces = (chess) random1.Next(0, 6);
Console.WriteLine(colors + " " + pieces);
}
}
}
}
So this is the right code. First of all you need to put enums before you class. Second of all you need to cast the randoms to your enums.
Good luck.