Beispiel #1
0
        public static void Main()
        {
            //------------------------------------------------------------------------
            // Build a collection of all vehicles that fly
            // With a single `foreach`, have each vehicle Fly()
            PassengerPlane plane1 = new PassengerPlane();
            PrivateJet     plane2 = new PrivateJet();
            Spaceship      plane3 = new Spaceship();
            //creat a list of planes
            var planes = new List <Aircraft>();

            planes.Add(plane1);
            planes.Add(plane2);
            planes.Add(plane3);
            //loop over the list with a foreach and call method Fly() for each one
            foreach (var plane in planes)
            {
                plane.Fly();
            }
            //--------------------------------------------------------------------------


            //------------------------------------------------------------------------
            // Build a collection of all vehicles that operate on roads
            // With a single `foreach`, have each road vehicle Drive()
            NissanLeaf  car1 = new NissanLeaf();
            NissanKicks car2 = new NissanKicks();
            NissanRogue car3 = new NissanRogue();
            //creat a list of cars
            var cars = new List <Car>();

            cars.Add(car1);
            cars.Add(car2);
            cars.Add(car3);
            //loop over the list with a foreach and call method Drive() for each one
            foreach (var car in cars)
            {
                car.Drive();
            }
            //--------------------------------------------------------------------------

            //--------------------------------------------------------------------------
            // Build a collection of all vehicles that operate on water
            // With a single `foreach`, have each water vehicle Drive()
            MotorBoat boat1 = new MotorBoat();
            RowBoat   boat2 = new RowBoat();
            Yacht     boat3 = new Yacht();
            //creat a list of boat
            var boats = new List <Watercraft>();

            boats.Add(boat1);
            boats.Add(boat2);
            boats.Add(boat3);
            //loop over the list with a foreach and call method Drive() for each one
            foreach (var boat in boats)
            {
                boat.Drive();
            }
            //--------------------------------------------------------------------------
        }
 public string CreateYacht(string model, int weight, string engineModel, int cargoWeight)
 {
     IBoatEngine engine = this.Database.Engines.GetItem(engineModel);
     IBoat boat = new Yacht(model, weight, engine, cargoWeight);
     this.Database.Boats.Add(boat);
     return string.Format("Yacht with model {0} registered successfully.", model);
 }
Beispiel #3
0
 /// <summary>
 /// Új yacht beírása az adatbázisba
 /// </summary>
 /// <param name="yacht"></param>
 /// <returns></returns>
 public bool MysqlAddYacht(Yacht yacht)
 {
     try
     {
         string query = "INSERT INTO enYacht(yacht_id, name, producer, ower, seats, width, lenght, dive, speed) VALUES (?yacht_id, ?name, ?producer, ?ower, ?seats, ?width, ?lenght, ?dive, ?speed);";
         Globals.connect.Open();
         using (MySqlCommand cmd = new MySqlCommand(query, Globals.connect))
         {
             cmd.Parameters.Add("?yacht_id", MySqlDbType.Int16).Value   = MysqlGeneral.MysqlNextId("enYacht", "yacht_id");
             cmd.Parameters.Add("?name", MySqlDbType.VarChar).Value     = yacht.nev;
             cmd.Parameters.Add("?producer", MySqlDbType.VarChar).Value = yacht.gyarto;
             cmd.Parameters.Add("?ower", MySqlDbType.Int16).Value       = yacht.member_id;
             cmd.Parameters.Add("?seats", MySqlDbType.Int16).Value      = yacht.ferohely;
             cmd.Parameters.Add("?width", MySqlDbType.Float).Value      = yacht.szeles;
             cmd.Parameters.Add("?lenght", MySqlDbType.Float).Value     = yacht.hossz;
             cmd.Parameters.Add("?dive", MySqlDbType.Float).Value       = yacht.merules;
             cmd.Parameters.Add("?speed", MySqlDbType.Int16).Value      = yacht.sebesseg;
             cmd.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         MessageBox.Show("Error in adding mysql row. Error: " + ex.Message);
         return(false);
     }
     finally
     {
         Globals.connect.Close();
     }
     return(true);
 }
Beispiel #4
0
        public ActionResult GetYacht()
        {
            Yacht newYacht = new Yacht(Request.Form["yacht"]);

            newYacht.Save();
            return(View("YachtList", Yacht.GetAll()));
        }
        public async Task <IActionResult> Edit(string id, [Bind("YachtId,Name,Price,Description")] Yacht yacht)
        {
            if (id != yacht.YachtId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _yachtRepository.Update(yacht);
                    await _unitOfWork.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    var temp = await YachtExists(yacht.YachtId);

                    if (!temp)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(yacht));
        }
Beispiel #6
0
        public ucYacht(int id)
        {
            // label tömb létrehozása, adatokkal való feltöltése

            InitializeComponent();
            data = new MysqlYacht();
            if (Globals.selectedYacht != null && id == Globals.selectedYacht.id)
            {
                Yacht = Globals.selectedYacht;
            }
            else
            {
                Yacht = data.MysqlYachtSelect(id);
            }
            lbAdatok = new Label[]
            {
                lbNev, lbMerul, lbHossz, lbFoglalt, lbAr, lbBerelheto, lbSeb, lbUlesek, lbHely, lbSzel, lbGyarto
            };
            Port_name();
            YachtImgLoad(false);
            LabelFeltolt();
            lbId.Content = Yacht.id.ToString();

            //Felhasználó id és yacht id összehasonlítása

            if (Globals.User.member_id == Yacht.member_id || Globals.User.login.admin)
            {
                btModosit.Visibility = Visibility.Visible;
                btBerles.Visibility  = Visibility.Hidden;
            }
            Globals.UpdateHistory();
        }
        public string CreateYacht(string model, int weight, string engineModel, int cargoWeight)
        {
            IBoatEngine engine = this.Database.Engines.GetItem(engineModel);
            IBoat       boat   = new Yacht(model, weight, cargoWeight, engine);

            this.Database.Boats.Add(boat);
            return(string.Format("Yacht with model {0} registered successfully.", model));
        }
Beispiel #8
0
        public string CreateYacht(string model, int weight, string engineModel, int cargoWeight)
        {
            var engine = this.Database.Engines.GetItem(engineModel);
            var boat   = new Yacht(model, weight, cargoWeight, engine);

            this.Database.Boats.Add(boat);
            return($"Yacht with model {model} registered successfully.");
        }
Beispiel #9
0
 public IActionResult Details(int?id)
 {
     if (id.HasValue)
     {
         Yacht p = _context.Products.Find(id.Value);
         return(View(p));
     }
     return(NotFound());
 }
        public string CreateYacht(string model, int weight, string engineModel, int cargoWeight)
        {
            var   engine = this.Database.Engines.GetItem(engineModel);
            IBoat boat   = new Yacht(model, weight, engine, cargoWeight);

            this.Database.Boats.Add(boat);

            return(string.Format(Constants.SuccessfullCreateBoat, "Yacht", model));
        }
Beispiel #11
0
 private void EditYacht(Yacht yacht)
 {
     yacht.Name        = GetName();
     yacht.Purpose     = GetPorp();
     yacht.Weight      = GetWeight();
     yacht.Waterline   = GetWLine();
     yacht.Сonsumption = GetCons();
     yacht.Type        = GetYachtType();
     yacht.Drive       = GetDrive();
 }
        public async Task <IActionResult> Create([Bind("YachtId,Name,Price,Description")] Yacht yacht)
        {
            if (ModelState.IsValid)
            {
                _yachtRepository.Add(yacht);
                await _unitOfWork.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(yacht));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Description,PriceHighSeason,PriceOffSeason,Image,Size,Year,Cabins,AirCond")] Yacht yacht)
        {
            if (ModelState.IsValid)
            {
                _context.Add(yacht);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(yacht));
        }
Beispiel #14
0
 public void SetYacht(Yacht yacht)
 {
     receivedYacht = yacht;
     SetName(yacht.Name);
     SetPorp(yacht.Purpose);
     SetWeight(yacht.Weight);
     SetWLine(yacht.Waterline);
     SetCons(yacht.Сonsumption);
     SetYachtType(yacht.Type);
     SetDrive(yacht.Drive);
 }
Beispiel #15
0
    public static void Main()
    {
        // Build a collection of all vehicles that fly
        List <IAir> aircrafts = new List <IAir>();
        C5          galaxy    = new C5();

        aircrafts.Add(galaxy);
        Cessna bird = new Cessna();

        aircrafts.Add(bird);
        Boieng747 southwest = new Boieng747();

        aircrafts.Add(southwest);
        // With a single `foreach`, have each vehicle Fly()
        foreach (var air in aircrafts)
        {
            air.Fly();
        }

        // Build a collection of all vehicles that operate on roads
        List <ILand> rovers     = new List <ILand>();
        Motorcycle   motorcycle = new Motorcycle();
        StationWagon leBaron    = new StationWagon();
        Lancer       lancer     = new Lancer();

        rovers.Add(motorcycle);
        rovers.Add(leBaron);
        rovers.Add(lancer);
        // With a single `foreach`, have each road vehicle Drive()
        foreach (var rover in rovers)
        {
            rover.Drive();
        }

        // Build a collection of all vehicles that operate on water
        List <IWater> floats   = new List <IWater>();
        JetSki        yamaha   = new JetSki();
        Speedboat     smuggler = new Speedboat();
        Yacht         money    = new Yacht();

        floats.Add(yamaha);
        floats.Add(smuggler);
        floats.Add(money);
        // With a single `foreach`, have each water vehicle Drive()
        foreach (var floaties in floats)
        {
            floaties.Drive();
        }
    }
Beispiel #16
0
 private void ButSave_Click(object sender, EventArgs e)
 {
     if (receivedYacht == null)
     {
         Yacht yacht = new Yacht();
         yacht.TypeName = TypeNames.yacht;
         EditYacht(yacht);
         FMain.AddVehicle(yacht);
     }
     else
     {
         EditYacht(receivedYacht);
     }
     Close();
 }
Beispiel #17
0
    public static void Main()
    {
        // Build a collection of all vehicles that fly
        Cessna newCessna = new Cessna();
        Boeing newBoeing = new Boeing();

        List <IAir> airVehicles = new List <IAir>();

        airVehicles.Add(newCessna);
        airVehicles.Add(newBoeing);

        // With a single `foreach`, have each vehicle Fly()
        foreach (var vehicle in airVehicles)
        {
            vehicle.Fly();
        }

        // Build a collection of all vehicles that operate on roads
        Motorcycle newCycle = new Motorcycle();
        BMW        newBmw   = new BMW();

        List <IGround> groundVehicles = new List <IGround>();

        groundVehicles.Add(newCycle);
        groundVehicles.Add(newBmw);

        // With a single `foreach`, have each road vehicle Drive()
        foreach (var vehicle in groundVehicles)
        {
            vehicle.Drive();
        }

        // Build a collection of all vehicles that operate on water
        JetSki newJetski = new JetSki();
        Yacht  newYacht  = new Yacht();

        List <IWater> waterVehicles = new List <IWater>();

        waterVehicles.Add(newJetski);
        waterVehicles.Add(newYacht);

        // With a single `foreach`, have each water vehicle Drive()
        foreach (var vehicle in waterVehicles)
        {
            vehicle.Drive();
        }
    }
Beispiel #18
0
        static void Main(string[] args)
        {
            List <string>  strListe1 = new List <string>();
            IList <string> strListe2 = new List <string>();

            Garage garage = new Garage();

            try
            {
                BobbyCar  bobbyCar  = new BobbyCar("Lalelu", "Turboschnuller 2.0", 2020, 3, "Rot", 50);
                PKW       pkw       = new PKW("VW", "Passat", 1992, 120, "Blau", 4, 4);
                PKW       pkw1      = new PKW("Ferrari", "Rote Göttin", 2001, 320, "Rot", 2, 4);
                Yacht     yacht     = new Yacht("Gib'Sea", "Ver 1.1", 1982, 10, "hellblau", 2.1, true);
                Yacht     yacht1    = new Yacht("Wester", "Nautilus1", 1999, 12, "gelb", 3.1, false);
                Tretboot  tretboot  = new Tretboot("Opas Best Boats", "SimpleBoat 1.0", 2010, 2, "Blau", 0.3, 2);
                Tretboot  tretboot1 = new Tretboot("Omas Best Boats", "SimpleBoat 2.0", 2010, 2, "Geld", 0.5, 2);
                Tretboot  tretboot2 = new Tretboot("Titanic Best Boats", "SimpleBoat 3.0", 2010, 2, "Orange", 0.6, 1);
                Jet       jet       = new Jet("Airbus", "X-Wing", 2055, 800, "Schwarz", 15.6, 36000, 0, 2, 2.8);
                Jet       jet1      = new Jet("Airbus", "Millenium Falke", 3001, 1800, "Grau", 15.6, 36000, 0, 2, 2.8);
                Propeller propeller = new Propeller("Fugger", "Albatros", 1915, 40, "Rot", 6.4, 4000, 0, 1, 1200);


                garage.Einparken(bobbyCar);
                garage.Einparken(pkw);
                garage.Einparken(pkw1);
                garage.Einparken(yacht);
                garage.Einparken(yacht1);
                garage.Einparken(tretboot);
                garage.Einparken(tretboot1);
                garage.Einparken(tretboot2);
                garage.Einparken(jet);
                garage.Einparken(jet1);
                garage.Einparken(propeller);

                bobbyCar.Baujahr = 1800;

                //Referenztypen, können im Nachgang noch den Inhalt einer Liste bearbeiten. Siehe am Beispiel BobbyCar
                BobbyCar clonedBobbyCar = (BobbyCar)bobbyCar.Clone();
                clonedBobbyCar.Baujahr = 1300;
                garage.Einparken(clonedBobbyCar);

                garage.DisplayInventar();
            }
            catch (FahrzeugMaxException ex)
            {
            }
        }
Beispiel #19
0
    public static void Main()
    {
        // Build a collection of all vehicles that fly
        Cessna         dylan  = new Cessna();
        Helicopter     cat    = new Helicopter();
        List <IFlying> flying = new List <IFlying>();

        flying.Add(dylan);
        flying.Add(cat);
        // With a single `foreach`, have each vehicle Fly()
        foreach (var thing in flying)
        {
            thing.Fly();
        }
        ;


        // Build a collection of all vehicles that operate on roads
        Motorcycle      heidi    = new Motorcycle();
        Car             spradlin = new Car();
        List <IDriving> driving  = new List <IDriving>();

        driving.Add(heidi);
        driving.Add(spradlin);
        // With a single `foreach`, have each road vehicle Drive()
        foreach (var thing2 in driving)
        {
            thing2.Drive();
        }
        ;


        // Build a collection of all vehicles that operate on water
        JetSki           edward  = new JetSki();
        Yacht            jerry   = new Yacht();
        List <IMaritime> sailing = new List <IMaritime>();

        sailing.Add(edward);
        sailing.Add(jerry);
        // With a single `foreach`, have each water vehicle Drive()
        foreach (var thing3 in sailing)
        {
            thing3.Drive();
        }
        ;
    }
Beispiel #20
0
 /// <summary>
 /// A beírt adatok eltárolása és átadása az adatbázisnak
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bt_Hozza_add(object sender, RoutedEventArgs e)
 {
     try
     {
         data               = new MysqlYacht();
         newYacht           = new Yacht();
         newYacht.nev       = tbYacht_nev.Text;
         newYacht.gyarto    = tbYacht_gyarto.Text;
         newYacht.member_id = TbYacht_tulaj.ID;
         newYacht.ferohely  = int.Parse(tbYacht_ferohely.Text);
         newYacht.sebesseg  = int.Parse(tbYacht_sebesseg.Text);
         newYacht.szeles    = (float)Convert.ToDouble(tbYacht_szeles.Text);
         newYacht.hossz     = (float)Convert.ToDouble(tbYacht_hossz.Text);
         newYacht.merules   = (float)Convert.ToDouble(tbYacht_merules.Text);
         ///Sikeres adatbeirás után visszajelzés az egyes usercontrolban valamint a hozzáadások táblában
         if (data.MysqlAddYacht(newYacht))
         {
             AddYachtLog(newYacht.nev + " Hozzáadva!");
             Globals.log = "Hozzáadás Sikeres! <Yacht>";
         }
         else
         {
             Globals.log = "Hozzáadás Sikertelen! <Yacht>";
         }
     }
     catch (Exception)
     {
         Globals.log = "Hozzáadás Sikertelen! <Yacht>";
     }
     finally
     {
         ///textboxok leüritése
         tbYacht_nev.Text      = "";
         tbYacht_gyarto.Text   = "";
         tbYacht_ferohely.Text = "";
         tbYacht_sebesseg.Text = "";
         tbYacht_szeles.Text   = "";
         tbYacht_hossz.Text    = "";
         tbYacht_merules.Text  = "";
     }
     Globals.Main.logAdd(true);
 }
Beispiel #21
0
        public static void Main()
        {
            var airbus  = new Airbus();
            var boeing  = new Boeing();
            var dinghy  = new Dinghy();
            var titanic = new Yacht();
            var sequoia = new Sequoia();
            var beetle  = new Beetle();

            // Build a collection of all vehicles that fly
            // With a single `foreach`, have each vehicle Fly()
            var flyings = new List <Aircraft> {
                airbus, boeing
            };

            foreach (var flying in flyings)
            {
                flying.Flying();
            }

            // Build a collection of all vehicles that operate on roads
            // With a single `foreach`, have each road vehicle Drive()
            var drivings = new List <Car> {
                sequoia, beetle
            };

            foreach (var driving in drivings)
            {
                driving.Driving();
            }

            // Build a collection of all vehicles that operate on water
            // With a single `foreach`, have each water vehicle Drive()
            var waterings = new List <Watercraft> {
                dinghy, titanic
            };

            foreach (var watering in waterings)
            {
                watering.Driving();
            }
        }
        public async Task <IActionResult> Edit(int id, Yacht yacht, Microsoft.AspNetCore.Http.IFormFile imageFile)
        {
            if (id != yacht.ID)
            {
                return(NotFound());
            }
            string newFile = System.IO.Path.Combine(_env.WebRootPath,
                                                    "images", imageFile.FileName);

            System.IO.FileInfo newFileInfo = new System.IO.FileInfo(newFile);

            using (System.IO.FileStream fs = newFileInfo.Create())
            {
                await imageFile.CopyToAsync(fs);

                fs.Close();
            }

            yacht.Image = "/images/" + imageFile.FileName;
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(yacht);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!YachtExists(yacht.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(yacht));
        }
Beispiel #23
0
 /// <summary>
 /// Yacht adatok frissitése az adatbázisba
 /// </summary>
 /// <param name="UpdateYacht"></param>
 public void MysqlUpdateYacht(Yacht UpdateYacht)
 {
     try
     {
         string query = "UPDATE enYacht SET name = ?name, producer = ?producer, image = ?image, seats = ?seats, hire = ?hire, busy = ?busy, daly_price = ?daly_price, width = ?width, lenght = ?lenght, dive = ?dive, speed = ?speed, port_id = ?port_id WHERE yacht_id = ?yacht_id;";
         Globals.connect.Open();
         using (MySqlCommand cmd = new MySqlCommand(query, Globals.connect))
         {
             cmd.Parameters.Add("?yacht_id", MySqlDbType.Int16).Value   = UpdateYacht.id;
             cmd.Parameters.Add("?name", MySqlDbType.VarChar).Value     = UpdateYacht.nev;
             cmd.Parameters.Add("?producer", MySqlDbType.VarChar).Value = UpdateYacht.gyarto;
             if (UpdateYacht.kep != null)
             {
                 cmd.Parameters.Add("?image", MySqlDbType.LongBlob).Value = MysqlGeneral.ImageToByte(UpdateYacht.kep);
             }
             else
             {
                 cmd.Parameters.Add("?image", MySqlDbType.LongBlob).Value = DBNull.Value;
             }
             cmd.Parameters.Add("?seats", MySqlDbType.Int16).Value      = UpdateYacht.ferohely;
             cmd.Parameters.Add("?hire", MySqlDbType.Bit).Value         = UpdateYacht.berelheto;
             cmd.Parameters.Add("?busy", MySqlDbType.Bit).Value         = UpdateYacht.blfoglalt;
             cmd.Parameters.Add("?daly_price", MySqlDbType.Int16).Value = UpdateYacht.napi_ar;
             cmd.Parameters.Add("?width", MySqlDbType.Float).Value      = UpdateYacht.szeles;
             cmd.Parameters.Add("?lenght", MySqlDbType.Float).Value     = UpdateYacht.hossz;
             cmd.Parameters.Add("?dive", MySqlDbType.Float).Value       = UpdateYacht.merules;
             cmd.Parameters.Add("?speed", MySqlDbType.Int16).Value      = UpdateYacht.sebesseg;
             cmd.Parameters.Add("?port_id", MySqlDbType.Int16).Value    = UpdateYacht.kikoto_id;
             cmd.ExecuteNonQuery();
         }
     }
     catch (MySqlException e)
     {
         Globals.log = "Sikertelen módosítás!";
         MessageBox.Show(e.ToString(), e.ToString(), MessageBoxButton.OK);
     }
     finally
     {
         Globals.connect.Close();
     }
 }
Beispiel #24
0
        public static double Tax(int year, int horsepower, string type)
        {
            double money;

            switch (type)
            {
            case "car": money = Car.Tax(horsepower, year); break;

            case "truck": money = Truck.Tax(horsepower, year); break;

            case "bike": money = Bike.Tax(horsepower); break;

            default: money = Yacht.Tax(horsepower); break;
            }

            DbFunc.AsyncDbAdd(new VehicleModel {
                Horsepower = horsepower, Year = year, Type = type, Tax = (int)money
            });

            return(money);
        }
Beispiel #25
0
        public Yacht MysqlYachtSelect(int id)
        {
            string full_name;
            Yacht  yacht = new Yacht();

            try
            {
                string query = "SELECT enPort.name AS port_name, enYacht.*, enYacht_Club_Tag.* FROM enYacht INNER JOIN enYacht_Club_Tag ON enYacht_Club_Tag.member_id = enYacht.ower INNER JOIN enPort USING(port_id) WHERE yacht_id = ?yacht_id AND hide = 0;";
                Globals.connect.Open();
                using (MySqlCommand cmd = new MySqlCommand(query, Globals.connect))
                {
                    cmd.Parameters.Add("?yacht_id", MySqlDbType.Int16).Value = id;
                    MySqlDataReader read = cmd.ExecuteReader();
                    while (read.Read())
                    {
                        yacht.member_id  = id;
                        yacht.berelheto  = false;
                        yacht.blfoglalt  = false;
                        yacht.strfoglalt = "Szabad";
                        yacht.id         = (int)read["yacht_id"];
                        yacht.nev        = read["name"].ToString();
                        yacht.gyarto     = read["producer"].ToString();
                        full_name        = read["first_name"].ToString();
                        full_name       += " " + read["last_name"].ToString();
                        yacht.full_name  = full_name;
                        if (read["renter"].ToString() == "")
                        {
                            yacht.berlo_full_name = "Nincs bérbe adva";
                            yacht.berlo_id        = 0;
                        }
                        else
                        {
                            yacht.berlo_id = (int)read["renter"];
                        }
                        yacht.ferohely = (int)read["seats"];
                        if ((int)read["hire"] == 1)
                        {
                            yacht.berelheto = true;
                        }
                        if ((int)read["busy"] == 1)
                        {
                            yacht.blfoglalt  = true;
                            yacht.strfoglalt = "Foglalt";
                        }
                        if (read["daly_price"].ToString() == "")
                        {
                            yacht.napi_ar = 0;
                        }
                        else
                        {
                            yacht.napi_ar = (int)read["daly_price"];
                        }
                        yacht.szeles    = (float)read["width"];
                        yacht.hossz     = (float)read["lenght"];
                        yacht.merules   = (float)read["dive"];
                        yacht.sebesseg  = (int)read["speed"];
                        yacht.kikoto    = read["port_name"].ToString();
                        yacht.kikoto_id = (int)read["port_id"];
                    }
                }
                yacht.berlo_full_name = MysqlMemberSelectFullname(yacht.berlo_id);
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error in adding mysql row. Error: " + ex.Message);
            }
            finally
            {
                Globals.connect.Close();
            }
            return(yacht);
        }
Beispiel #26
0
 public void Update(Yacht yacht)
 {
     _context.Update(yacht);
 }
Beispiel #27
0
 public void Delete(Yacht yacht)
 {
     _context.Remove(yacht);
 }
Beispiel #28
0
 public void Add(Yacht yacht)
 {
     _context.Add(yacht);
 }
        static void Main(string[] args)
        {
            #region Polymorphie Beispiel
            Flugzeug flugzeug  = new Flugzeug("Lufthansa", 2001, 500, "blau", 22, 11000);
            Flugzeug flugzeug1 = new Flugzeug("Fogger Doppedecker", 1912, 50, "Rot", 10, 2000);

            PKW pkw1 = new PKW("Ferrarie", 1955, 220, "Rot", 2, 4);
            PKW pkw2 = new PKW("Trappi", 1955, 80, "Mausegrau", 4, 4);
            PKW pkw3 = new PKW("Mercedez", 2020, 260, "Schwarz", 4, 4);


            Schiff schiff = new Schiff("Gorck Fork", 1867, 15, Schiff.SchiffsTreibstoff.Wind, 5);
            Yacht  yacht  = new Yacht("Jeanneau", 1999, 18, Schiff.SchiffsTreibstoff.Diesel, 2, true);
            Yacht  yacht1 = new Yacht("Black Pearl", 1788, 25, Schiff.SchiffsTreibstoff.Wind, 2, false);


            Garage dagobertsGarage = new Garage();
            dagobertsGarage.ParkeFahrzeugInGarage(flugzeug);
            dagobertsGarage.ParkeFahrzeugInGarage(flugzeug1);
            dagobertsGarage.ParkeFahrzeugInGarage(pkw1);
            dagobertsGarage.ParkeFahrzeugInGarage(pkw2);
            dagobertsGarage.ParkeFahrzeugInGarage(pkw3);
            dagobertsGarage.ParkeFahrzeugInGarage(schiff);
            dagobertsGarage.ParkeFahrzeugInGarage(yacht);
            dagobertsGarage.ParkeFahrzeugInGarage(yacht1);
            //Zeige mir mein Inventar der Garage an
            dagobertsGarage.WelcheFahrzeugeSindInDerGarage();
            dagobertsGarage.DoppeleAlleFahrzeugeDieEsKoennen();
            dagobertsGarage.WelcheFahrzeugeSindInDerGarage();

            Console.ReadKey();
            #endregion

            #region Hallo Lambda
            List <PKW> pkwListe = new List <PKW>();
            pkwListe.Add(pkw1);
            pkwListe.Add(pkw2);
            pkwListe.Add(pkw3);
            pkwListe.Add(new PKW("BMW", 2001, 180, "grau", 3, 3));
            pkwListe.Add(new PKW("BMW", 2002, 222, "rot", 4, 4));
            pkwListe.Add(new PKW("Mercedez", 2019, 300, "blau", 4, 4));


            List <PKW> filterdList = pkwListe.Where(n => n.AnzahlTueren == 4).ToList();

            //Labda benutzt das Fluent-Pattern: .LambdaMethode(n=>n.IrgendEineProperty==true).LambdaMethode(n=>n.IrgendEineProperty==true);
            List <PKW> filterdList1 = pkwListe.Where(n => n.Marke == "Mercedez" && n.MaxGeschwindigkeit > 100).OrderBy(n => n.Baujahr).ToList();

            //PKW resultPKW = pkwListe.Single(n => n.ID == "IregendeineGuid");

            //if (resultPKW != null)
            //{
            //    if (resultPKW.ID != Guid.Empty)
            //    {

            //    }
            //}


            #endregion

            #region Exception Benutzen
            //https://docs.microsoft.com/de-de/dotnet/standard/exceptions/best-practices-for-exceptions
            try
            {
                Console.Write("Eingabe>");
                string eingabe = Console.ReadLine();
                int    a       = int.Parse(eingabe);

                throw new MeineException();
            }
            catch (FormatException ex)
            {
                Console.WriteLine("Du musst eine Zahl eingeben.\n" + ex.Message);
                throw;
            }
            catch (OverflowException ex)
            {
                Console.WriteLine("Deine Zahl ist zu groß/klein.");
            }
            catch (MeineException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Ein unbekannter Fehler ist aufgetreten");
            }
            finally
            {
                Console.WriteLine("Wird immer ausgeführt");
            }


            StreamWriter sw = null;
            try
            {
                sw = new StreamWriter("zahlen.txt");

                for (int i = 0; i < 100; i++)
                {
                    sw.WriteLine(i);

                    if (i < 50)
                    {
                        continue;
                    }

                    Console.WriteLine(i);
                }
            }
            catch (Exception ex)
            {
                //Logdatei beschreiben
                throw;
            }
            finally
            {
                sw.Close();
            }


            #endregion
        }
        static void Main(string[] args)
        {
            Fahrzeug fahrzeug = new Fahrzeug();
            //Beispiel -> Param. Konstruktor
            Fahrzeug einFahrzeug      = new Fahrzeug("BMW", 2019, 220);
            Fahrzeug weiteresFahrzeug = new Fahrzeug("Audi", 2020, 250);

            Console.WriteLine($"Marke: {einFahrzeug.Marke} \t mit Baujahr: {einFahrzeug.Baujahr} \t besitzt eine maximale Geschwindigkeit von: {einFahrzeug.MaxGeschwindigkeit}");
            Console.WriteLine($"Marke: {weiteresFahrzeug.Marke} \t mit Baujahr: {weiteresFahrzeug.Baujahr} \t besitzt eine maximale Geschwindigkeit von: {weiteresFahrzeug.MaxGeschwindigkeit}");


            einFahrzeug.Beschleunige(100);
            double mphGeschwindigkeit = Fahrzeug.KmhToMph(einFahrzeug.AktGeschwindigkeit);

            Console.WriteLine($"{einFahrzeug.Marke} fährt {einFahrzeug.AktGeschwindigkeit} kmh und umgerechnet {mphGeschwindigkeit} mph");
            weiteresFahrzeug.Beschleunige(120);

            Console.WriteLine(Fahrzeug.ZeigeAnzahlFahrzeuge());


            #region Vererbung

            PKW pkw  = new PKW("BMW", 2019, 220, 4, 4);
            PKW pkw1 = new PKW("Ford", 2018, 180, 5, 4);

            pkw.Beschleunige(50);

            Console.WriteLine($"{pkw.Marke} \t {pkw.Baujahr} \t {pkw.MaxGeschwindigkeit} / {pkw.AktGeschwindigkeit} \t - Anzahl Türen: {pkw.AnzahlTueren} \t Anzahl Räder: {pkw.AnzahlRaeder}");

            Yacht yacht = new Yacht("Kühne", 1955, 12, Schiff.Schifftreibstoff.Diesel, 2, 2000000);


            Schiff schiff = new Schiff("BlubbBlubbWerft", 1954, 13, Schiff.Schifftreibstoff.Diesel, 2);
            #endregion

            Yacht yacht1 = new Yacht(schiff, 2000000, true);

            Console.ReadKey();


            Console.WriteLine("Garagen Beispiel - Polymorphie");

            Garage garage = new Garage();
            garage.Einparken(pkw);
            garage.Einparken(pkw1);
            garage.Einparken(schiff);
            garage.Einparken(yacht);

            foreach (Fahrzeug currentFahrzeug in garage.FahrzeugListe)
            {
                if (currentFahrzeug is ITuev)
                {
                    ITuev tuev = (ITuev)currentFahrzeug;
                    if (tuev.MussFahrzeugZumTüv())
                    {
                        Console.WriteLine("Muss zum Tuev");
                    }
                }
            }


            //List<PKW> resultList = garage.ZeigeAllePKWSInGarageAn();

            //foreach (PKW currentPKW in resultList)
            //{
            //    Console.WriteLine($"{currentPKW.Marke} \t {currentPKW.Baujahr} \t {currentPKW.MaxGeschwindigkeit} / {currentPKW.AktGeschwindigkeit} \t - Anzahl Türen: {currentPKW.AnzahlTueren} \t Anzahl Räder: {currentPKW.AnzahlRaeder}");

            //    if (currentPKW is ITuev)
            //    {
            //        Console.WriteLine("Hier kann man nach dem Tuevjahr prüfen)");

            //        if (currentPKW.MussFahrzeugZumTüv())
            //            Console.WriteLine("Muss zum Tüv");
            //    }
            // }


            //Dictionaries arbeitet mit der Klasse KeyValue
            Dictionary <string, PKW> autoRegister = new Dictionary <string, PKW>();
            Dictionary <Guid, PKW>   register2    = new Dictionary <Guid, PKW>();

            register2.Add(Guid.NewGuid(), pkw);
            register2.Add(Guid.NewGuid(), pkw1);

            Guid id = Guid.NewGuid();

            autoRegister.Add(id.ToString(), pkw);
            autoRegister.Add(Guid.NewGuid().ToString(), pkw1);

            //Contain Key
            if (autoRegister.ContainsKey(id.ToString()))
            {
                PKW pkw2 = (PKW)autoRegister[id.ToString()];
            }

            if (autoRegister.ContainsValue(pkw))
            {
            }

            //KeyValuePair ist für das Lesen von Dictionaries
            foreach (KeyValuePair <string, PKW> kvp in autoRegister)
            {
                Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
            }



            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            //unschönes Beispiel
            FahrzeugBase fahrzeug = new FahrzeugBase();

            fahrzeug.Baujahr            = 1999;
            fahrzeug.Marke              = "BMW";
            fahrzeug.Modell             = "Z8";
            fahrzeug.MaxGeschwindigkeit = 250;


            FahrzeugBase auto = new FahrzeugBase(1999, "BMW", "Z8", 250);

            FahrzeugBase autoVersion2 = new FahrzeugBase(2020, "Fiat", "Punto", 280, "Blau");

            autoVersion2.StarteMotor();
            autoVersion2.Beschleunigung(150);
            Console.WriteLine(autoVersion2.Display());
            autoVersion2.Beschleunigung(150);
            Console.WriteLine(autoVersion2.Display());



            //FahrzeugBase autoVersion3 = new FahrzeugBase(2019, "Fiat", "Punto", 130, "Blau");
            //FahrzeugBase autoVersion4 = new FahrzeugBase(2018, "BMW", "Z8", 220, "Rot");
            //FahrzeugBase autoVersion5 = new FahrzeugBase(2017, "Porsche", "xyz", 280, "Schwarz");
            //FahrzeugBase autoVersion6 = new FahrzeugBase(2016, "Audi", "Quatro", 240, "Sibler");


            FahrzeugBase.KmhToMph("123");


            Yacht yacht = new Yacht(2010, "DagobertDuckWerft", "Yacht 1.0", 20, "Blau", 1.2, true);

            yacht.AnkerAuswerfen();
            yacht.MakeParty();


            yacht.WartungsArbeitenInTage(); // bekomme 10

            Console.WriteLine(yacht.ToString());

            ContainerSchiff containerSchiff = new ContainerSchiff(1990, "Kühne Werft", "Blub Blub 1.0", 5, "grau", 2, 100, 20);

            containerSchiff.AnkerAuswerfen();
            containerSchiff.BeladeSchiff(50);


            BobbyCar orginalBobbyCar = new BobbyCar("Toy1.0", "Model123", 2019, 1, "rot", 50);


            //Eine neue Kopie wird übergeben. Neuer Speicherbereich
            BobbyCar kopiertesBobbyCar = (BobbyCar)orginalBobbyCar.Clone();

            //Speicheradresse wird hier übergeben
            BobbyCar weitereKopieBobbyCar = orginalBobbyCar;


            ChangeBobyCar(kopiertesBobbyCar);
            ChangeBobyCar(weitereKopieBobbyCar);

            Console.WriteLine(orginalBobbyCar.Farbe);
            Console.ReadKey();
        }