import hashmap

# creata a mapping of state to abbbreviation
states = hashmap.new()
hashmap.set(states, 'Oregon', 'OR')
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

# add some more cities
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

# print out some cities
print '-' * 10
print "NY states has: %s" % hashmap.get(cities, 'NY')
print "OR states has: %s" % hashmap.get(cities, 'OR')

# print some states
print '-' * 10
print "Michigan's abbbreviation is: %s" % hashmap.get(states, 'Michigan')
print "Florida's abbbreviation is: %s" % hashmap.get(states, 'Florida')

# do it by using the states then citis dict
print '-' * 10
print "Michigan has: %s" % hashmap.get(cities, hashmap.get(states, 'Michigan'))
print "Florida has: %s" % hashmap.get(cities, hashmap.get(states, 'Florida'))

# print every state abbbreviation
print '-' * 10
hashmap.list(states)

# print every city in state
print '-' * 10
hashmap.list(cities)

# now do both at the same time
# print '-' * 10
# for state, abbrev in states.items():
# 	print "%s state is abbriviated %s and has city %s" % (state, abbrev, cities[abbrev])

print '-' * 10
# safely get a abbbreviation by state that might not be there
state = hashmap.get(states, 'Texas')

if not state:
	print "Sorry, no Texas."

# get a city with a defaul value
city = hashmap.get(cities, 'TX', 'Does Not Exist')
print "The city for the state 'TX' is: %s" % city

print states
print cities