Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a class called House to hold details of the location (street number, st

ID: 3916589 • Letter: 1

Question

1. Write a class called House to hold details of the location (street number, street name, town) and the year of construction and the property tax. Write the appropriate contructor, selector and mutator methods. Also write a toString method to return the details of the house.

2. Write a subclass Home with additional instance fields for the name of the occupying family and the date they moved in. You should use the OurDate class we wrote in the class.

Note the following: There should be two overloaded constructor methods: public Home (int house, String street, String town, String family, OurDate movedIn) and public Home (int house, String street, String town, int yearConstructed, int propertyTax, String family, OurDate movedIn) These should make use of the super keyword where appropriate. There should be the usual methods to set and extract the values of the new instance fields: setFamily getFamily setDateMovedIn getDateMovedIn There should be a toString method that calls the toString method provided by the House class to return the details of the house and then return the text "has been occupied by FAMILY since DATE", with suitable values inserted. You should make the three classes (House, Home, OurDate) part of the package insy.java.hw6.

3. Write a simple driver application that prompts the user to enter the appropriate information about a home, creates an instance of the Home class, and then prints out the details of that home. Make sure to use the appropriate import statement(s) to import the above classes.

Explanation / Answer

1.Addess.java:

public class Address

{
private String street number, street name, town;
public Address (String street, String name, String town)
{
streetNumber = street;
town=city;
name = nam;

} //It Returns the Address object as a String.

public String toString()
{
String result;

result = streetNumber + " ";
result += town + ", " + name;

return result;
}  
}

2)Home.java:

public class Home extends House
{
private String family;
private String f;
int OurDate movedIn;
OurDate mi;

public Home (int house, String street, String town, String family, OurDate movedIn)
{
super( house, street, town, family );
f = "None";
}
public Home (int house, String street, String town, int yearConstructed,int propertyTax, String family, OurDate movedIn)
{
private int yearConstructed=yc;
private int propertyTax=pt;
super( house, street, town, family, yc, pt );
  
setfamily( f );
setmovedIn( mi );
  
}
public String getfamily( String f )
{
return f;
}
  
public OurDate getmovedIn( int mi )
{
return mi;
}
  
public String toString( )
{
  
return super.toString() + "occupied by " + family + " considering " + mi + ".";
  
}
  
}

public class House
{
private String family f;
private String street s;
private String town t;
public House()//defult constructor
{
h = 0;
s = "Non";
t = "Non";
yc = 0;
pt = 0;
}
public House( int h, String s, String t, int yc, int pt )
{
setfamily( f);
setstreet( s );
settown( t );
setyearConstructed( yc );
setpropertyTax( pt );
}
  
//accessor methods or selector methods
public String setfamily(String f )
{
return f;
}
  
public String getfamily( String f )
{}
public int getDateMovedIn(int d){
return d;
}

public int getDateMovedIn(int d){}

public String toString( )
{
  
return "The family is date moved in at " + family + DateMovedIn+".";
  
}
  
}

3)HomeDriver.java:

package HomeDriver;
  
import javax.swing.*;
public class HomeDriver
{
public static void main( String[] arg )
{
  
private String family f;
private String street s;
private String town t;
  
HomeDriver home;
home = new HomeDriver( );
input = Integer.parseInt( JOptionPane.showInputDialog(
"Please enter one of the following: "
  
+ "1 - to get the family "
+ "2 - to set the family "
+ "3 - to get the OurDate movedIn "
+ "4 - to set the OurDate movedIn "
+ "5 - to print the object as string "
+ "0 - to quit " ) );
  
while ( input != 0 )
{
  
switch ( input )
{
case 0: System.exit(0);
break;
JOptionPane.showMessageDialog( null,
"Your family name is " + f + "." );
break;
case 1: f = Integer.parseInt( JOptionPane.showInputDialog(
"Please enter the family name:"));
break;
  
case 2: home.setfamily( f );
  
JOptionPane.showMessageDialog( null,
"The family name is " + f + ".");
break;
  
case 3: l = Integer.parseInt( JOptionPane.showInputDialog(
"Please enter the length of the Rectangle:"));
break;
  
case 4: rect.setlength( l );
  
JOptionPane.showMessageDialog( null,
"The length is set at " + l + "." );
break;
  
case 5: mi = Integer.parseInt( JOptionPane.showInputDialog(
"Please enter the date when you moved in to your another house:"));
break;
  
case 6: home.setlength( mi );
  
JOptionPane.showMessageDialog( null,
"The date you moved in is " + mi + "." );
break;
  
case 0: JOptionPane.showMessageDialog( null,family );
break;
}
  
//dialog box with options 0-15 to enter in house attributes
input = Integer.parseInt( JOptionPane.showInputDialog(
+ "1 - to get the family name "
+ "2 - to set the family name "
+ "3 - to get the moved in date "
+ "4 - to set the moved in "
+ "5 - to print the object as string "
+ "0 - to quit " ) );
  
}
  
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote