Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago