Exemplo n.º 1
0
 public static Gorilla[] GetGorilla(namesKaiju name, int numberName, float version, int distanceOfJump, int count)
 {
     if (numberName > 0 & count > 0)
     {
         Gorilla[] masGorilla = new Gorilla[count];
         for (int i = 0; i < masGorilla.Length; i++)
         {
             masGorilla[i] = new Gorilla(distanceOfJump, name.ToString() + numberName++, version);
         }
         return masGorilla;
     }
     else
     {
         throw new System.Exception("The parameter is incorrect!");
     }
 }
Exemplo n.º 2
0
 //public Kaiju GetKaijuByID(int kaijuId)
 //{
 //    if (kaijuId > 0)
 //    {
 //        for (int i = 0; i < countKaiju; i++)
 //        {
 //            if (masKaiju[i].ID == kaijuId)
 //            {
 //                return masKaiju[i];
 //            }
 //        }
 //        Kaiju temp = new Kaiju();
 //        temp = null;
 //        return temp;
 //    }
 //    else
 //    {
 //        throw new System.ArgumentException("KaijyId<=0");
 //    }
 //}
 public Gorilla[] GetArrayGorilla()
 {
     Kaiju[] k1 = GetArrayForName("Gorilla");
     Gorilla[] g1 = new Gorilla[k1.Length];
     for (int i = 0; i < k1.Length; i++)
     {
         g1[i] = (Gorilla)k1[i];
     }
     return g1;
 }
Exemplo n.º 3
0
        public Kaiju[] ReadFile()
        {
            int counterObj = CountObjInFile();
            Kaiju[] resultArrayKaiju = new Kaiju[counterObj];
            StreamReader sr = new StreamReader(Resource_1.pathSaveKaiju);
            string[] ArrayStringData;
            string tempString;
            string name=null;
            float version = 0;
            int id;
            float thicknessOfTitanium=0;
            int levelOfLibido=0;
            int lightningStrikes=0;
            int distanceOfJump=0;
            int flightSpeed=0;

            for (int i = 0; i < counterObj; i++)
            {
                tempString = sr.ReadLine();
                ArrayStringData = ParseString(tempString);
                for (int j = 0; j < ArrayStringData.Length; j++)
                {
                    if (ArrayStringData[j].IndexOf("id") > -1)
                    {
                        Int32.TryParse(ArrayStringData[j + 1], out id);
                    }
                    if (ArrayStringData[j].IndexOf("Name") > -1)
                    {
                        name = ArrayStringData[j + 1];
                    }
                    if (ArrayStringData[j].IndexOf("Version") > -1)
                    {
                        float.TryParse(ArrayStringData[j + 1], out version);
                    }
                    if (ArrayStringData[j].IndexOf("ThicknessOfTitanium") > -1)
                    {
                        float.TryParse(ArrayStringData[j + 1], out thicknessOfTitanium);
                    }
                    if (ArrayStringData[j].IndexOf("LevelOfLibido") > -1)
                    {
                        Int32.TryParse(ArrayStringData[j + 1], out levelOfLibido);
                    }
                    if (ArrayStringData[j].IndexOf("LightningStrikes") > -1)
                    {
                        Int32.TryParse(ArrayStringData[j + 1], out lightningStrikes);
                    }
                    if (ArrayStringData[j].IndexOf("DistanceOfJump") > -1)
                    {
                        Int32.TryParse(ArrayStringData[j + 1], out distanceOfJump);
                    }
                    if (ArrayStringData[j].IndexOf("FlightSpeed") > -1)
                    {
                        Int32.TryParse(ArrayStringData[j + 1], out flightSpeed);
                    }
                }
                switch (ArrayStringData[0])
                {
                    case "Kaiju":
                        resultArrayKaiju[i] = new Kaiju(name, version);
                        break;
                    case "Titan":
                        resultArrayKaiju[i] = new Titan(thicknessOfTitanium, name, version);
                        break;
                    case "Apollon":
                        resultArrayKaiju[i] = new Apollon(levelOfLibido, thicknessOfTitanium, name, version);
                        break;
                    case "Zeus":
                        resultArrayKaiju[i] = new Zeus(lightningStrikes, thicknessOfTitanium, name, version);
                        break;
                    case "Gorilla":
                        resultArrayKaiju[i] = new Gorilla(distanceOfJump, name, version);
                        break;
                    case "Flying":
                        resultArrayKaiju[i] = new Flying(flightSpeed, name, version);
                        break;
                }
            }
            sr.Close();

            return resultArrayKaiju;
        }