Question: JAVA Implement a class Address. An address has a house number, a street, an optional apartment number, a city, a state, and a postal code
JAVA
Implement a class Address. An address has a house number, a street, an optional apartment number, a city, a state, and a postal code (all of these are strings). Create the getters and setters.
Supply two constructors that accept all the address components except one includes an apartment number and one without (refer to the tester class below to see the proper order).
Supply a print method that returns void and prints to the console the address with the street on one line and the city, state, and zip code on the next line.
use this tester you can pass test
public class AddressTester {
public static void main(String[] args) { Address home = new Address("145","New Street","Iowa City", "IA","50321"); home.print(); System.out.println("----------------"); Address condo = new Address("5633", "Old Mountain", "3C","Nashville", "TN", "37115"); condo.print(); }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
