Exemple #1
0
 //metoda kupująca wagon
 private void buttonBuyWagon_Click(object sender, EventArgs e)
 {
     //warunek kupna wagonu: aktualna ilość złota >= 50 oraz gra nie może być zapauzowana
     if (money >= 50 && Counter % 2 == 0 && wagonUpgrade == 0)
     {
         //tworzenie obiektu klasy wagon
         Wagon wagon = new Wagon();
         //dodanie do listy
         Wagons.Add(wagon);
     }
     if (wagonUpgrade == 1)
     {
         //tworzenie obiektu klasy UpgradedWagon
         UpgradedWagon upgradedWagon = new UpgradedWagon();
         Wagons.Add(upgradedWagon);
     }
     if (wagonUpgrade == 2)
     {
         //tworzenie obiektu klasy MasterWagon
         MasterWagon masterWagon = new MasterWagon();
         Wagons.Add(masterWagon);
     }
     //liczba elementów listy wagonów
     howManyWagons = Wagons.Count;
     //zmiana liczby wagonów wyświeltanych w textboxie
     textBoxHowManyWagons.Text = howManyWagons.ToString();
 }
Exemple #2
0
        public bool UpdateWagon(Wagon wagon)
        {
            int index = Wagons.FindIndex(w => w.Id == wagon.Id);

            Wagons[index] = wagon;
            return(true);
        }
Exemple #3
0
        public void AddWagon(Animal animal)
        {
            Wagon wagon = new Wagon();

            wagon.AddAnimal(animal);
            Wagons.Add(wagon);
        }
Exemple #4
0
 public void CheckWagonSearcher()
 {
     //If there are wagons check first if J is bigger or equal than the Wagons
     if (J >= Wagons.Count())
     {
         //If j is bigger or equal rest J back to 0
         J = 0;
     }
 }
Exemple #5
0
 public void Add(Wagon wagon) //Add a wagon to train
 {
     if (wagon != null)
     {
         Wagons.Add(wagon);
     }
     else
     {
         throw new ArgumentNullException("wagon");
     }
 }
Exemple #6
0
        private Wagon FindNewWagon()
        {
            if (Wagons == null)
            {
                Wagons = new List <Wagon>();
            }

            Wagon _newWagon = new Wagon();

            Wagons.Add(_newWagon);
            return(_newWagon);
        }
Exemple #7
0
        public void CloseWagons()
        {
            WagonSpace = 0;
            CheckFlag  = true;
            int wagonCount = Wagons.Count();

            for (int i = 0; i < wagonCount; i++)
            {
                ClosedWagons.Add(Wagons[0]);
                Wagons.Remove(Wagons[0]);
            }
        }
Exemple #8
0
        public bool Remove(Wagon wagon) // remove wagon
        {
            if (wagon == null)
            {
                throw new ArgumentNullException("wagon");
            }

            Wagon w = FindWagon(wagon.WagonNumber);

            if (w != null)
            {
                Wagons.Remove(w); //remove from list
                if (OnWagonUpdate != null)
                {
                    OnWagonUpdate(this, w, false);
                }
                return(true);
            }
            return(false);
        }
Exemple #9
0
        public bool Add(Wagon wagon) //add wagon
        {
            if (wagon == null)
            {
                throw new ArgumentNullException("wagon");
            }

            Wagon w = FindWagon(wagon.WagonNumber);

            if (w == null)
            {
                Wagons.Add(wagon); //add to list

                if (OnWagonUpdate != null)
                {
                    OnWagonUpdate(this, wagon, true);
                }
                return(true);
            }
            return(false);
        }
Exemple #10
0
 public Train(Locomotive locomotive, List <Wagon> wagons) : this()
 {
     Locomotive = locomotive;
     Wagons.AddRange(wagons);
 }
Exemple #11
0
 public void WagonToevoegen(Wagon wagon)
 {
     Wagons.Add(wagon);
 }
Exemple #12
0
 public Station(string name, IEnumerable <Wagon> wagons, IEnumerable <Locomotive> locomotives) : this()
 {
     Name = name;
     Wagons.AddRange(wagons);
     Locomotives.AddRange(locomotives);
 }
Exemple #13
0
        public Wagon GetWagonbyId(long id)
        {
            Wagon wagon = Wagons.FirstOrDefault(w => w.Id == id);

            return(wagon);
        }
Exemple #14
0
 public long CreateWagon(Wagon wagon)
 {
     Wagons.Add(wagon);
     return(wagon.Id);
 }
Exemple #15
0
 public bool DeleteWagon(long id)
 {
     Wagons.FirstOrDefault(w => w.Id == id).Actief = false;
     return(true);
 }