package insy.java.hw6; import javax.swing.*; /** A simple class that stores info
ID: 3916714 • Letter: P
Question
package insy.java.hw6;
import javax.swing.*;
/**
A simple class that stores information about a Home
**/
public class Home extends House
{
private String familyName;
private OurDate movedIn;
// overload Constructors
public Home(int house, String street, String town, String family, OurDate movedIn)
{
//super(streetname, town, streetnumber, yearConstructed, propertyTax);
setFamilyName (familyName);
setMovedIn (movedIn);
}
public Home( int house, String street , String town, int yearConstructed, int propertyTax, String family, OurDate movedIn )
{
super(house, street, town);
setFamilyName (family);
setMovedIn (movedIn);
}
// selector methods
public String getFamilyName()
{
return familyName;
}
public OurDate getMovedIn()
{
return movedIn();
}
public void setFamilyName( String familyName)
{
return familyName;
}
public void setMoveIn( OurDate movedIn)
{
movedIn = movedIn();
}
// overriding toString()
public String toString()
{
return super.toString() + " has been occupied by" +familyName+ "since" +movedIn;
}
// override equals
public boolean equals( Object o )
{
Home h = (Home)o;
if ( ( super.equals( h ) ) &&
( familyName.equals( h.getFamilyName() ) ) &&
( OurDate movedIn.equals(h.getMovedIn() ) )
return true;
return false;
}
This is my Home class I created but its not recognized the House class I made and its has some errors. help please.
package insy.java.hw6;
/**
A simple class that stores information about a person
**/
public class House
{
private String streetname, town;
private int streetnumber, yearConstructed , propertyTax;
private static int count = 0;
// constructors
public House ()
{
this("NONE", "NONE", 0, 0, 0);
}
/**
overloaded constructor
@param strname - Street Name
@param t - Town
@param strno - Street Number
@param yearConstructed - Year Constructed
@param propertyTax - Property Tax
**/
//overloaded constructor
public House (String strname, String t, int strno, int yearConstructed, int propertyTax)
{
setStreetname( strname );
setTown( t );
setStreetnumber(strno);
setYearConstructed(yearConstructed);
setPropertyTax( propertyTax );
count++;
}
//selectors methods
public int getCount()
{
return count;
}
public String getStreetname()
{
return streetname;
}
public String getTown()
{
return town;
}
public int getStreetnumber()
{
return streetnumber;
}
public int getYearConstructed()
{
return yearConstructed;
}
public int getPropertyTax()
{
return propertyTax;
}
//mutator methods
public void setStreetname( String strname)
{
streetname = strname;
}
public void setTown( String t)
{
town = t;
}
public void setStreetnumber( int strno)
{
streetnumber = strno;
}
public void setYearConstructed( int yrcon)
{
yearConstructed = yrcon;
}
public void setPropertyTax( int propT)
{
propertyTax = propT;
}
//overriding toString
public String toString()
{
return "Street Name: " + streetname + " Town:" + town + " Street Number:" + streetnumber + " Year Constructed:" + yearConstructed + " Property Tax:" + propertyTax;
}
//override equals
public boolean equals ( Object o )
{
House h = (House) o;
if ( ( streetname.equals(h.getStreetname() ) ) &&
( town.equals(h.getTown() ) ) &&
( streetnumber == h.getStreetnumber() ) &&
( yearConstructed == h.getYearConstructed() ) &&
( propertyTax == h.getPropertyTax() ) )
return true;
return false;
}
}
house Class.
Explanation / Answer
Please check now. I have corected the errors I understood. In Home constructor you arr calling super class constrcutor with some parameters but there is no matching constrcutor in that class. I have added that. So I am attaching both the classes here.
Home.java
import javax.swing.*;
/**
A simple class that stores information about a Home
**/
public class Home extends House
{
private String familyName;
private OurDate movedIn;
// overload Constructors
public Home(int house, String street, String town, String family, OurDate movedIn)
{
//super(streetname, town, streetnumber, yearConstructed, propertyTax);
setFamilyName (familyName);
setMovedIn (movedIn);
}
public Home( int house, String street , String town, int yearConstructed, int propertyTax, String family, OurDate movedIn )
{
super(house, street, town);
setFamilyName (family);
setMovedIn (movedIn);
}
// selector methods
public String getFamilyName()
{
return familyName;
}
public OurDate getMovedIn()
{
return movedIn;
}
public String setFamilyName( String familyName)
{
return familyName;
}
public void setMovedIn( OurDate movedIn)
{
this.movedIn = movedIn;
}
// overriding toString()
public String toString()
{
return super.toString() + " has been occupied by" +familyName+ "since" +movedIn;
}
// override equals
public boolean equals( Object o )
{
Home h = (Home)o;
if ( ( this.equals( h ) ) &&
( familyName.equals( h.getFamilyName() ) ) &&
( movedIn.equals(h.getMovedIn() ) ))
return true;
return false;
}
}
House.java
public class House
{
private String streetname, town;
private int streetnumber, yearConstructed , propertyTax;
private static int count = 0;
// constructors
public House ()
{
this("NONE", "NONE", 0, 0, 0);
}
/**
overloaded constructor
@param strname - Street Name
@param t - Town
@param strno - Street Number
@param yearConstructed - Year Constructed
@param propertyTax - Property Tax
**/
//overloaded constructor
public House (String strname, String t, int strno, int yearConstructed, int propertyTax)
{
setStreetname( strname );
setTown( t );
setStreetnumber(strno);
setYearConstructed(yearConstructed);
setPropertyTax( propertyTax );
count++;
}
public House(int house, String street, String town2) {
// TODO Auto-generated constructor stub
}
//selectors methods
public int getCount()
{
return count;
}
public String getStreetname()
{
return streetname;
}
public String getTown()
{
return town;
}
public int getStreetnumber()
{
return streetnumber;
}
public int getYearConstructed()
{
return yearConstructed;
}
public int getPropertyTax()
{
return propertyTax;
}
//mutator methods
public void setStreetname( String strname)
{
streetname = strname;
}
public void setTown( String t)
{
town = t;
}
public void setStreetnumber( int strno)
{
streetnumber = strno;
}
public void setYearConstructed( int yrcon)
{
yearConstructed = yrcon;
}
public void setPropertyTax( int propT)
{
propertyTax = propT;
}
//overriding toString
public String toString()
{
return "Street Name: " + streetname + " Town:" + town + " Street Number:" + streetnumber + " Year Constructed:" + yearConstructed + " Property Tax:" + propertyTax;
}
//override equals
public boolean equals ( Object o )
{
House h = (House) o;
if ( ( streetname.equals(h.getStreetname() ) ) &&
( town.equals(h.getTown() ) ) &&
( streetnumber == h.getStreetnumber() ) &&
( yearConstructed == h.getYearConstructed() ) &&
( propertyTax == h.getPropertyTax() ) )
return true;
return false;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.