/// <summary> /// Constructor for Place_Serialised taking seperate values. /// For creating Place_Serialised from CSV file. /// </summary> /// <param name="id">String holding place ID</param> /// <param name="nam">String holding place name</param> /// <param name="own">String holding Place owner (ID)</param> /// <param name="tiHo">String holding place title holder (charID)</param> /// <param name="rnk">String holding Place rank (ID)</param> public Place_Serialised(String id, String nam, byte r, String tiHo = null, string own = null) { // VALIDATION // ID // trim and ensure is uppercase id = id.Trim().ToUpper(); if (!Utility_Methods.ValidatePlaceID(id)) { throw new InvalidDataException("Place_Serialised id must be 5 characters long, start with a letter, and end in at least 2 numbers"); } // NAM // trim and ensure 1st is uppercase nam = Utility_Methods.FirstCharToUpper(nam.Trim()); if (!Utility_Methods.ValidateName(nam)) { throw new InvalidDataException("Place_Serialised name must be 1-40 characters long and contain only valid characters (a-z and ') or spaces"); } // TIHO if (!String.IsNullOrWhiteSpace(tiHo)) { // trim and ensure 1st is uppercase tiHo = Utility_Methods.FirstCharToUpper(tiHo.Trim()); if (!Utility_Methods.ValidateCharacterID(tiHo)) { throw new InvalidDataException("Place_Serialised titleHolder must have the format 'Char_' followed by some numbers"); } } // OWNER if (!String.IsNullOrWhiteSpace(owner)) { // trim and ensure 1st is uppercase owner = Utility_Methods.FirstCharToUpper(owner.Trim()); if (!Utility_Methods.ValidateCharacterID(owner)) { throw new InvalidDataException("Place_Serialised owner must have the format 'Char_' followed by some numbers"); } } this.id = id; this.name = nam; this.owner = own; this.titleHolder = tiHo; this.rank = r; }
/// <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; }