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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started