Question: Address Class Application Using Python Implement the class Address. An address object has a house number, a street, an optional apartment number, a city, a

Address Class Application

Using Python Implement the class Address. An address object has a house number, a street, an optional apartment number, a city, a state, and a postal code. Define the constructor such that an object can be created in one of two ways: with an apartment number or without. Supply a print method that prints the address with the street on one line and the city, state, and postal code on the next line. Supply the method def comesBefore(self, other) that tests whether an address comes before another when compared by postal code. Finally, supply the def getCountry(self) method that indicates the country in which the address is located.

Note: To complete this assignment, you will need to use the addressdemo.py file located in Project 11 folder on Blackboard. You will not be allowed to make any changes to addressdemo.py. All addresses are assumed to be in the USA by default.

addressdemo.py from address import Address # Construct two objects. a = Address(2500, "University Drive", "Turlock", "CA", "95382") b = Address(1200, "College Blvd", "Merced", "CA", "95340", "Apt 12") # Demonstrate the print method. print("1st address:") a.print() print() print("2nd address:") b.print() print() # Demonstrate the comesBefore method. a.comesBefore(b) # Demonstrate that all addresses are in the USA. print("1st address is in the", a.getCountry()) print("2nd address is in the", b.getCountry()) 

-------------------------------------------------------------------------------------------

SAMPLE RUN

1st address:

2500 University Drive

Turlock, CA 95382

2nd address:

Apt 12 - 1200 College Blvd

Merced, CA 95340

2nd address comes before 1st address

1st address is in the USA

2nd address is in the USA

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!