Question: Write a class named Address.java that represents an address with the following fields and methods with suitable access modifiers: Two string fields for street and

Write a class named Address.java that represents an address with the following fields and methods with suitable access modifiers: Two string fields for street and city, an integer field for zip code. The Address class has the following methods: 1. Address(String street, String city, int zip): assigns the parameters to the class data fields. 2. Address( Address D) : a copy constructor. 3. getStreet() : returns the street value 4. getCity(): returns the city value. 5. getZip(): returns the zip value. 6. toString(): returns a string of the Address object in the following form: street. City, zip example: Wadeljoz. Jerusalem, 1234 7. isSameCity(Address a): returns true if this Address object and a object has same city. B)Write another class named Person.java that has the following: 1. A string field name. 2. An Address field add. Class Person has the following methods: 1. Person(String name, Address add) : assigns the parameters to the class data fields. 2. Person(String name, String street, String city, int zip): assigns the parameters to the class data fields. 3. getName(): return the name of person. 4. getAddress(): returns the address of person. 5. setAddress(Address add): assigns the parameter to the this object Address. 6. toString(): returns a string in the following form: Person name: Ahmad Address: Wadeljoz. Jerusalem, 1234 7. LiveInTheSameCity(Person p): returns true if Person object p has the same city value of this Person object. 2 a) Write a tester class Test.java that initialize and print Address and Person objects for Saeed Halawany who lives in (Wadeljoz, Jerusalem, 1234), examine and output if Saeed lives in the same city where you live.

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!