13.5k views
0 votes
Define a class, addresstype, that can store a street address, city, state, and zip code. use the appropriate functions to print and store the address. also, use constructors to automatically initialize the member variables

User Waki
by
8.3k points

1 Answer

2 votes

We will use Python for this task.
class addrestype(object):
# Constructor to initialize member variables
def __init__(self, addr, city, state, zip):
self.address = addr
self.city = city
self.state = state
self.zip = zip
# Function to print the address (overrides behavior of builtin "print")
def __str__(self): return self.address + ", " + self.city + ", " + self.state + ", " + str(self.zip)

User Cjm
by
7.9k points