Assignment is to define a class named Address. The Address class will have three private instance variables: an int named street_number a String named street_name and a String named state. Write three constructors for the Address class: an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice, a constructor that takes the street values as input but defaults the state to "Arizona", and a constructor that takes all three pieces of information as input Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses. Run your code to make sure it works.  Next add the following public methods to the Address class and test them from main as you go: Write getters and setters for all the instance variables The setter for street number should make sure the street number is greater than zero otherwise it sets the street number to one. Override the default equals method with an equals method that returns true if the input Address has the same values as this. Your method header will look like: public boolean equals(Object other)    Be aware that you will need to cast other to a variable of type Address. Refer to this example: https://www.geeksforgeeks.org/overriding-equals-method-in-java/ Override the default toString method: public String toString() Write a method named isNeighbor which returns true if street name and state are equal and street number is off by one. Use the following method header: public boolean isNeighbor(Address other) This needs to be about to upload in completed Address.java and Main.java files separately or zipped together.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Instructions-Java

Assignment is to define a class named Address.

The Address class will have three private instance variables:

  • an int named street_number
  • a String named street_name
  • and a String named state.

Write three constructors for the Address class:

  • an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice,
  • a constructor that takes the street values as input but defaults the state to "Arizona",
  • and a constructor that takes all three pieces of information as input

Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses.

Run your code to make sure it works. 

Next add the following public methods to the Address class and test them from main as you go:

  • Write getters and setters for all the instance variables
    • The setter for street number should make sure the street number is greater than zero otherwise it sets the street number to one.
  • Override the default equals method with an equals method that returns true if the input Address has the same values as this. Your method header will look like: public boolean equals(Object other)    Be aware that you will need to cast other to a variable of type Address. Refer to this example: https://www.geeksforgeeks.org/overriding-equals-method-in-java/
  • Override the default toString method: public String toString()
  • Write a method named isNeighbor which returns true if street name and state are equal and street number is off by one. Use the following method header: public boolean isNeighbor(Address other)

This needs to be about to upload in completed Address.java and Main.java files separately or zipped together.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education