Beispiel #1
0
        //static methods
        //fills a fish array with random fish types
        static Fish[] StockAquarium(int numfish, Random rand)
        {
            Fish[] fishies = new Fish[numfish];
            int    gene;

            Console.WriteLine("*****Stocking the aquariumS!*****");
            for (int i = 0; i < fishies.Length; i++)
            {
                gene = rand.Next(0, 4);
                switch (gene)
                {
                case 0:
                    fishies[i] = new PShrimp(rand);
                    break;

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

                case 2:
                    fishies[i] = new Knifefish("Ghost Knife " + i, rand);
                    break;

                case 3:
                    fishies[i] = new Fish(rand);
                    break;
                }
            }
            return(fishies);
        }
Beispiel #2
0
 //partners gobies to pshrimp
 static void PartnerGoby(Fish[] fi)
 {
     Console.WriteLine("Attempting to partner goby fish...");
     foreach (Fish fin in fi)
     {
         if (fin is Goby)
         {
             Goby gob = (Goby)fin;
             gob.ChoosePShrimp(fi);
         }
     }
 }
 //constructor
 public PShrimp(Random rand) : base(rand)
 {
     partner = null;
     shape   = " D-xѺѺX:༄ ";
     price   = rand.Next(18, 24);
 }