Esempio n. 1
0
        //method stock aquarium
        //int parameter and random object parameter
        //return fish array
        static public Fish[] StockAquarium(int numFish, Random rand)
        {
            //declare fish array
            Fish[] fishes = new Fish[numFish];
            //print infor
            Console.WriteLine("*****Stocking the aquariums!*****");
            //for loop to create random fishes
            for (int i = 0; i < numFish; i++)
            {
                int gene;               //create a viable to hold random number
                gene = rand.Next(0, 4); //assign random number
                //sweitch to create random fishes
                switch (gene)
                {
                case 0:
                    fishes[i] = new PShrimp(rand);
                    break;

                case 1:
                    fishes[i] = new Goby("Goby", rand);
                    break;

                case 2:
                    fishes[i] = new KnifeFish("Ghost Knife", rand);
                    break;

                default:
                    fishes[i] = new Fish(rand);
                    break;
                }
            }
            return(fishes);    //return fishes array
        }
Esempio n. 2
0
 //constructor
 public PShrimp(Random _myRand) : base(_myRand)
 {
     partner = null;
     shape   = " D-xѺѺX:༄ ";
     price   = (double)myRand.Next(18, 24);
 }