Exemplo n.º 1
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="station">The station.</param>
 public TrainStation(TrainStation station)
 {
     this.id           = station.id;
     this.stationName  = station.stationName;
     this.inhabitation = station.inhabitation;
     this.townCategory = station.townCategory;
     this.track        = station.track;
     this.trainLines   = station.trainLines;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the default values for variables.
        /// </summary>
        private void setDefaultValues()
        {
            id                  = -1;
            stationName         = "";
            trainLines          = new List <TrainLine>();
            track               = -1;
            minimalTransferTime = MINIMAL_TRANSFER_TIME_DEFAULT;
            townCategory        = TownCategory.medium;
            updateInhabitation();
            updateMinimalTransferTime();

            transfers = new List <Transfer>();
        }
Exemplo n.º 3
0
        private Boolean townCategoryValueChanged()
        {
            Boolean changed = true;

            TownCategory newTownCategory = (TownCategory)comboBoxCategory.SelectedValue;

            // if the value of townCategory has not changed
            if (newTownCategory.Equals(trainStation.TownCategory))
            {
                changed = false;
            }

            return(changed);
        }
        /// <summary>
        /// Calculates the town category according the inhabitation.
        /// </summary>
        /// <param name="inhabitation">The inhabitation.</param>
        /// <returns></returns>
        public static TownCategory calculateCategory(int inhabitation)
        {
            TownCategory category = TownCategory.small;

            TownCategory[] enums;
            enums = (TownCategory[])Enum.GetValues(typeof(TownCategory));
            foreach (TownCategory cat in enums)
            {
                if (inhabitation > (int)cat)
                {
                    category = cat;
                }
                else
                {
                    break;
                }
            }

            return(category);
        }
        /// <summary>
        /// Calculates the time according town category.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public static Time calculateTime(TownCategory category)
        {
            int    minutes      = 5;
            String nameCategory = Enum.GetName(typeof(TownCategory), category);

            // map Minimal Transfer Time into two arrays (string and value array)
            String[] namesMTT = Enum.GetNames(typeof(MinimalTransferTime));
            MinimalTransferTime[] arrayMTT = (MinimalTransferTime[])Enum.GetValues(typeof(MinimalTransferTime));

            // find index according the name of item
            int index = find(namesMTT, nameCategory);

            if (index != -1)
            {
                // retreive value according the index
                MinimalTransferTime mtt = (MinimalTransferTime)arrayMTT.GetValue(index);
                minutes = (int)mtt;
            }
            //int minutes = (int) mtt;
            return(Time.ToTime(minutes));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Updates the town category according the inhabitation value.
 /// </summary>
 public void updateTownCategory()
 {
     townCategory = TownCategoryUtil.calculateCategory(inhabitation);
 }
 /// <summary>
 /// Calculates the inhabitation according the town category.
 /// </summary>
 /// <param name="category">The category.</param>
 /// <returns></returns>
 public static int calculateInhabitation(TownCategory category)
 {
     return((int)category);
 }