Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StatePriceChecker
- {
- Dictionary<String, int> StatePrices = new Dictionary<String, int>
- {
- { "alabama", 213 }, { "alaska", 523 }, { "arizona", 202 }
- // etc. etc.
- }
- Dictionary<String, String> StateAltNameForms = new Dictionary<String, int>
- {
- { "al", "alabama" }, { "alab", "alabam"}, { "albm", "alabama"}, { "alabam", "alabama" },
- { "alask", "alaska" }, { "alsk", "alaska" },
- { "ar", "arizona" }, { "ariz", "arizona" }, { "arzn", "arizona" }, { "arizon", "arizona" }
- // etc. etc.
- }
- public int GetPrice(String State)
- {
- State = State.ToLower();
- if(StateAltNameForms.TryGetValue(State, out String AltForm))
- State = AltForm;
- if(StatePrices.TryGetValue(State, out int Price))
- return Price;
- else
- throw new ArgumentException(State + " is not a state.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment