예제 #1
0
        /// <summary>
        /// Constructor for Province
        /// </summary>
        /// <param name="otax">Double holding province tax rate</param>
        /// <param name="king">Province's Kingdom object</param>
        public Province(String id, String nam, Double otax, String tiHo = null, PlayerCharacter own = null, Kingdom king = null, Rank r = null)
            : base(id, nam, tiHo, own, r)
        {
            // VALIDATION

            // OTAX
            if (!Utility_Methods.ValidatePercentage(otax))
            {
                throw new InvalidDataException("Province taxrate must be a double between 0 and 100");
            }

            this.taxRate = otax;
            this.kingdom = king;
        }
예제 #2
0
        /// <summary>
        /// Constructor for Province_Serialised taking seperate values.
        /// For creating Province_Serialised from CSV file.
        /// </summary>
        /// <param name="otax">Double holding province tax rate</param>
        /// <param name="king">string holding Province's Kingdom (id)</param>
        public Province_Serialised(String id, String nam, byte r, Double otax, String tiHo = null, string own = null, string king = null)
            : base(id, nam, r, own: own, tiHo: tiHo)
        {
            // VALIDATION

            // OTAX
            if (!Utility_Methods.ValidatePercentage(otax))
            {
                throw new InvalidDataException("Province_Serialised taxrate must be a double between 0 and 100");
            }

            // KING
            // trim and ensure is uppercase
            king = king.Trim().ToUpper();

            if (!Utility_Methods.ValidatePlaceID(king))
            {
                throw new InvalidDataException("Province_Serialised kingdom ID must be 5 characters long, start with a letter, and end in at least 2 numbers");
            }

            this.taxRate = otax;
            this.kingdom = king;
        }