public MessershmittWarplaneBuilder()
 {
     _warplane = new Warplane()
     {
         Name = "Messerschmitt Bf 109"
     };
 }
예제 #2
0
 public SpitfireWarplaneBuilder()
 {
     _warplane = new Warplane()
     {
         Name = "Supermarine Spitfire"
     };
 }
예제 #3
0
 public void AddPlane(Warplane plane)
 {
     if (!PlaneCollection.Contains(plane))
     {
         PlaneCollection.Add(plane);
     }
 }
예제 #4
0
 public void Init()
 {
     p1 = new Warplane {
         WarplaneID = 1, Name = "P1"
     };
     p2 = new Warplane {
         WarplaneID = 2, Name = "P2"
     };
     sut = new Comparison();
 }
예제 #5
0
 public ActionResult Delete(int id, Warplane plane)
 {
     try
     {
         // TODO: Add delete logic here
         repo.RemovePlane(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View("Error"));
     }
 }
예제 #6
0
 public ActionResult Edit(int id, Warplane plane)
 {
     try
     {
         // TODO: Add update logic here
         repo.SavePlane(plane);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View("Error"));
     }
 }
예제 #7
0
 public ActionResult Create(Warplane plane)
 {
     try
     {
         // TODO: Add insert logic here
         repo.SavePlane(plane);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View("Error"));
     }
 }
예제 #8
0
        public Warplane BuildWarplane(string name)
        {
            Warplane warplane = _factory.CreateWarplane(name);

            if (warplane == null)
            {
                return(null);
            }
            warplane.Fly();
            warplane.Shoot();
            warplane.Reload();
            warplane.Repair();
            return(warplane);
        }
예제 #9
0
        public void Cant_Delete_unexisted_plane()
        {
            sut.AddPlane(p1);
            sut.AddPlane(p2);
            var p3 = new Warplane()
            {
                WarplaneID = 3, Name = "P3"
            };
            var results = sut.Planes.OrderBy(x => x.Name).ToArray();

            sut.RemovePlane(p3);
            Assert.AreEqual(results.Length, 2);
            Assert.AreEqual(results[0], p1);
            Assert.AreEqual(results[1], p2);
        }
예제 #10
0
 public void SavePlane(Warplane plane)
 {
     if (plane.WarplaneID == 0)
     {
         context.Warplanes.Add(plane);
     }
     else
     {
         Warplane dbEntry = context.Warplanes.Find(plane.WarplaneID);
         if (dbEntry != null)
         {
             dbEntry.Name              = plane.Name;
             dbEntry.Description       = plane.Description;
             dbEntry.Country           = plane.Country;
             dbEntry.Category          = plane.Category;
             dbEntry.Description       = plane.Description;
             dbEntry.PlaneImageUrl     = plane.PlaneImageUrl;
             dbEntry.Generation        = plane.Generation;
             dbEntry.Crew              = plane.Crew;
             dbEntry.Length            = plane.Length;
             dbEntry.Wingspan          = plane.Wingspan;
             dbEntry.Height            = plane.Height;
             dbEntry.WingArea          = plane.WingArea;
             dbEntry.EmptyWeight       = plane.EmptyWeight;
             dbEntry.MaximumWeight     = plane.MaximumWeight;
             dbEntry.FuelWeight        = plane.FuelWeight;
             dbEntry.EngineName        = plane.EngineName;
             dbEntry.EngineDescription = plane.EngineDescription;
             dbEntry.EngineWeight      = plane.EngineWeight;
             dbEntry.MaximumSpeed      = plane.MaximumSpeed;
             dbEntry.MaxRange          = plane.MaxRange;
             dbEntry.FlightDuration    = plane.FlightDuration;
             dbEntry.Ceiling           = plane.Ceiling;
         }
     }
     context.SaveChanges();
 }
예제 #11
0
 public void RemovePlane(Warplane plane) => PlaneCollection.Remove(plane);