Question: public class Home { public static void main ( String [ ] args ) { HomeListing [ ] listings = new HomeListing [ 2 ]
public class Home
public static void mainString args
HomeListing listings new HomeListing;
listings new ListingWithDetails Old Route "All mailboxes have to be identical.";
listings new RentalListing Old Time Way", ;
for HomeListing listing : listings
listing.priceListing;
public abstract class HomeListing
protected int id;
protected String address;
protected double squareFootage;
protected int bedrooms;
protected double listPrice;
public HomeListingint id String address, double squareFootage, int bedrooms
setIdid;
setAddressaddress;
setSquareFootagesquareFootage;
setBedroomsbedrooms;
setListPricelistPrice;
public abstract void priceListing;
public HomeListing
this;
public int getId
return id;
public void setIdint id
if id
this.id id;
else
System.out.printlnInvalid;
public String getAddress
return address;
public void setAddressString address
this.address address;
public double getSquareFootage
return squareFootage;
public void setSquareFootagedouble squareFootage
if squareFootage
this.squareFootage squareFootage;
else
System.out.printlnInvalid;
public int getBedrooms
return bedrooms;
public void setBedroomsint bedrooms
if bedrooms
this.bedrooms bedrooms;
else
System.out.printlnInvalid;
public double getListPrice
return listPrice;
public void setListPricedouble listPrice
if listPrice
this.listPrice listPrice;
else
System.out.printlnInvalid;
public String toString
return String.formatID: d Address: s Square Footage: f Bedrooms: d
id address, squareFootage, bedrooms;
class ListingWithDetails extends HomeListing
private double monthlyFee;
private String specialDetails;
public ListingWithDetailsint id String address, double squareFootage, int bedrooms, double listPrice, double monthlyFee, String specialDetails
superid address, squareFootage, bedrooms;
setListPricelistPrice; Ensure setListPrice is called
setMonthlyFeemonthlyFee;
setSpecialDetailsspecialDetails;
public double getMonthlyFee
return monthlyFee;
public void setMonthlyFeedouble monthlyFee
if monthlyFee
this.monthlyFee monthlyFee;
else
System.out.printlnInvalid;
public String getSpecialDetails
return specialDetails;
public void setSpecialDetailsString specialDetails
this.specialDetails specialDetails;
public void priceListing
System.out.printlnStringformatID: d Address: s Square Footage: f Bedrooms: d List Price: f Monthly Fee: f Special Details: s
id address, squareFootage, bedrooms, getListPrice monthlyFee, specialDetails;
class RentalListing extends HomeListing
private double monthlyRent;
private double depositAmount;
public RentalListingint id String address, double squareFootage, int bedrooms, double monthlyRent, double depositAmount
superid address, squareFootage, bedrooms;
setMonthlyRentmonthlyRent;
setDepositAmountdepositAmount;
public double getMonthlyRent
return monthlyRent;
public void setMonthlyRentdouble monthlyRent
if monthlyRent
this.monthlyRent monthlyRent;
else
System.out.printlnInvalid;
public double getDepositAmount
return depositAmount;
public void setDepositAmountdouble depositAmount
if depositAmount
this.depositAmount depositAmount;
else
System.out.printlnInvalid;
public void priceListing
System.out.printlnStringformatID: d Address: s Square Footage: f Bedrooms: d Monthly Rent: f First Month's Rent: f
id address, squareFootage, bedrooms, monthlyRent, monthlyRent depositAmount;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
