Ejemplo n.º 1
0
        public override string Serialize(Bolid serializableBolid)
        {
            List <string> propertiesCollection = new List <string>();
            string        str          = "{";
            string        strclass     = "class:";
            string        strname      = "name:";
            string        strengine    = "engine:";
            string        strbody      = "body:";
            string        strNose      = "nose:";
            string        strRearWing  = "rearwing:";
            string        strDownForce = "downforce:";
            string        strFrontWing = "frontwing:";

            strclass     = String.Concat(strclass, "Bolid80;");
            strname      = String.Concat(String.Concat(strname, serializableBolid.name), ";");
            strengine    = String.Concat(String.Concat(strengine, serializableBolid.engine), ";");
            strbody      = String.Concat(String.Concat(strbody, serializableBolid.body), ";");
            strNose      = string.Concat(strNose, (serializableBolid as Bolid80).nose, ";");
            strRearWing  = String.Concat(strRearWing, (serializableBolid as Bolid80).RearWing, ";");
            strDownForce = String.Concat(strDownForce, (serializableBolid as Bolid80).DownForce, ";");
            strFrontWing = String.Concat(strFrontWing, (serializableBolid as Bolid80).FrontWing, ";");
            propertiesCollection.Add(str);
            propertiesCollection.Add(strclass);
            propertiesCollection.Add(strname);
            propertiesCollection.Add(strengine);
            propertiesCollection.Add(strbody);
            propertiesCollection.Add(strNose);
            propertiesCollection.Add(strRearWing);
            propertiesCollection.Add(strDownForce);
            propertiesCollection.Add(strFrontWing);
            propertiesCollection.Add("}");
            str = String.Concat(propertiesCollection);
            return(str);
        }
Ejemplo n.º 2
0
        public string Serialize()
        {
            bolid = bolid as Bolid60;
            List <string> propertiesCollection = new List <string>();
            string        str       = "{";
            string        strclass  = "class:";
            string        strname   = "name:";
            string        strengine = "engine:";
            string        strbody   = "body:";
            string        strnose   = "nose:";

            strclass  = String.Concat(strclass, "Bolid60;");
            strname   = String.Concat(String.Concat(strname, bolid.name), ";");
            strengine = String.Concat(String.Concat(strengine, bolid.engine), ";");
            strbody   = String.Concat(String.Concat(strbody, bolid.body), ";");
            strnose   = String.Concat(strnose, (bolid as Bolid60).nose, ";");
            propertiesCollection.Add(str);
            propertiesCollection.Add(strclass);
            propertiesCollection.Add(strname);
            propertiesCollection.Add(strengine);
            propertiesCollection.Add(strbody);
            propertiesCollection.Add(strnose);
            propertiesCollection.Add("}");
            str = String.Concat(propertiesCollection);
            return(str);
        }
Ejemplo n.º 3
0
        public override Bolid FactoryMethod(Bolid bolid, List <string> fields)
        {
            Bolid60 car = (Bolid60)bolid;

            fields.Add(car.name);
            fields.Add(car.engine);
            fields.Add(car.body);
            fields.Add(car.nose);
            return(car);
        }
Ejemplo n.º 4
0
 private int GetIndexOfHandler(Bolid player)
 {
     for (int i = 0; i < CarsVarietyRepository.ListCars.Count; i++)
     {
         if (player.ToString().Contains("Bolid: " + CarsVarietyRepository.ListCars[i]))
         {
             return(i);
         }
     }
     return(-1);
 }
Ejemplo n.º 5
0
        public override Bolid FactoryMethod(Bolid bolid, List <string> fields)
        {
            Bolid80 car = (Bolid80)bolid;

            fields.Add(car.name);
            fields.Add(car.engine);
            fields.Add(car.body);
            fields.Add(car.nose);
            fields.Add(car.RearWing);
            fields.Add(car.DownForce);
            fields.Add(car.FrontWing);
            return(car);
        }
Ejemplo n.º 6
0
        public override Bolid FactoryMethod(Bolid bolid, List <string> fields)
        {
            NewBolid car = (NewBolid)bolid;

            fields.Add(car.name);
            fields.Add(car.engine);
            fields.Add(car.body);
            fields.Add(car.nose);
            fields.Add(car.RearWing);
            fields.Add(car.DownForce);
            fields.Add(car.FrontWing);
            fields.Add(car.Turbo);
            fields.Add(car.Kers);
            fields.Add(car.Drs);
            return(car);
        }
Ejemplo n.º 7
0
        public void comboBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <string> fields = new List <string>();

            currentBolid         = (Bolid)comboBoxObjects.SelectedItem;
            currentComboboxIndex = comboBoxObjects.SelectedIndex;
            int index = GetIndexOfHandler(currentBolid);

            comboBoxBolids.SelectedIndex = index;
            editingCreator = EditingCreatorRepository.ListOfEditingCreators[comboBoxBolids.SelectedIndex];
            editingCreator.FactoryMethod(currentBolid, fields);
            HandlerFromFields handler = HandlersRepository.ListOfHandlers[comboBoxBolids.SelectedIndex];

            ChangeFieldAccordingWithHandler(handler);
            FillFields(fields);
            changeModFlag = true;
            //bolidsRepository.Bolid.RemoveAt(currentComboboxIndex);
        }
Ejemplo n.º 8
0
        public override string Serialize(Bolid serializableBolid)
        {
            List <string> propertiesCollection = new List <string>();
            Bolid         bolid     = serializableBolid as FirstBolid;
            string        str       = "{";
            string        strclass  = "class:";
            string        strname   = "name:";
            string        strengine = "engine:";
            string        strbody   = "body:";

            strclass  = String.Concat(strclass, "FirstBolid;");
            strname   = String.Concat(String.Concat(strname, bolid.name), ";");
            strengine = String.Concat(String.Concat(strengine, bolid.engine), ";");
            strbody   = String.Concat(String.Concat(strbody, bolid.body), ";");
            propertiesCollection.Add(str);
            propertiesCollection.Add(strclass);
            propertiesCollection.Add(strname);
            propertiesCollection.Add(strengine);
            propertiesCollection.Add(strbody);
            propertiesCollection.Add("}");
            str = String.Concat(propertiesCollection);
            return(str);
        }
Ejemplo n.º 9
0
        public static void Race(object x)
        {
            Bolid bolid = (Bolid)x;

            Console.WriteLine("Team name {0}, Max speed {1} km/h, Power {2} h.p., Tank volume {3}", bolid.TeamName, bolid.MaxSpeed, bolid.CarPower, bolid.TankVolume);
            DistanceMonitoring distanceMonitoring = new DistanceMonitoring();

            averageSpeed      = bolid.GetAverageSpeed();
            bolid.RaceTime    = 5;
            startAcceliration = bolid.StartAcceleration(averageSpeed);
            Console.Write("First start {0}, {1} m/s^2 ", bolid.TeamName, startAcceliration);
            distanceToFinish = distanceMonitoring.PrintFirstCoveredDistance(startAcceliration);
            while (distanceToFinish <= distanceMonitoring.FullDistance)
            {
                bolid.RaceTime++;
                Console.WriteLine("");
                Thread.Sleep(1000);
                averageSpeed        = bolid.GetMaxSectionSpeed();
                sectionAcceliration = bolid.SectionAcceleration(averageSpeed);
                Console.Write("{0}, {1} m/s^2, {2} m ", bolid.TeamName, sectionAcceliration, distanceToFinish);
                distanceToFinish = distanceMonitoring.PrintCoverDistance(sectionAcceliration, distanceToFinish);
            }
            bolid.ManualResetEvent.Set();
        }
Ejemplo n.º 10
0
 public abstract string Serialize(Bolid serializableBolid);
Ejemplo n.º 11
0
 public FirstBolidSerializer(FirstBolid obj)
 {
     this.bolid = obj;
 }
Ejemplo n.º 12
0
 public NewBolidSerializer(NewBolid obj)
 {
     this.bolid = obj;
 }
Ejemplo n.º 13
0
 public BolidTurboSerializer(BolidTurbo obj)
 {
     this.bolid = obj;
 }
Ejemplo n.º 14
0
 public BolidAtmoSerializer(BolidAtmo obj)
 {
     this.bolid = obj;
 }
Ejemplo n.º 15
0
 public Bolid60Serializer(Bolid60 obj)
 {
     this.bolid = obj;
 }