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

ASSIGNMENT: Make sure you are in the RealEstate.java file when you compile and r

ID: 3560131 • Letter: A

Question

ASSIGNMENT:

Make sure you are in the RealEstate.java file when you compile and run. If you have no run-time errors and your output matches the output in the last page, you are ready to begin making the modifications in the next step.

1. Modify the .java files and create your own as necessary to accomplish the following tasks:

a. Remove the abstract monthlyFee method from the abstract Property class. Create a monthlyFee Interface with a single method that returns a double, is named monthlyFee, and receives no arguments. You will need to implement the interface just once, with the Property class (let inheritance take care overriding the method).

b. The boss acquired 2 new Mobile Home Park properties to manage

Explanation / Answer

Please find the solution as per the requirements and steps

CODE:

public class RealEstate

{

public static void main (String[] args)

{

Portfolio properties = new Portfolio();

properties.assessFees();

}

}
/*
* Run your program.
* You should have 3 new properties at the end of the listing.
* When everything is checked and running perfectly,
* copy the output from the Console and paste it into a comment
* block after the end of your main method in the RealEstate.java file.
* ---------------------OUTPUT------------------------------------
Property Owner: Jabba The Hutt
Location: 123 Main Line
Property ID: C-75
Property Manager: Boba Fett
Monthly Percentage Rent fee: 137.5
Total Fees: 2560.57
------------------------------------------
Property Owner: Donald Trump
Location: 1 Trump Tower
Property ID: B-221
Property Manager: Omarosa
Total Fees: 1246.15
------------------------------------------
Property Owner: Tony Stark
Location: 789 Off Rocker
Property ID: B-59
Property Manager: Pepper Potts
Total Fees: 1169.23
------------------------------------------
Property Owner: Nick Fury
Location: 678 Fifth Ave.
Property ID: R-154
Property Manager: Phil Coulson
Current number of occupied units: 21
Total Fees: 431.55
------------------------------------------
Property Owner: Jack Bauer
Location: 987 Suds Blvd.
Property ID: Chloe
Public service to the community!
------------------------------------------
Property Owner: Lone Ranger
Location: 321 Duds Lane
Property ID: Tonto
Public service to the community!
------------------------------------------
Property Owner: My Name1
Location: My address1
Property ID: MYID1
Property Manager: My Manager1
Current number of occupied units: 16
Total Fees: 483.84
------------------------------------------
Property Owner: My Name2
Location: My address2
Property ID: MYID2
Property Manager: My Manager2
Current number of occupied units: 21
Total Fees: 1559.88
------------------------------------------
Property Owner: Mname resi
Location: My add resi.
Property ID: Resi ID
Property Manager: Phil Coulson
Current number of occupied units: 50
Total Fees: 1760.5
------------------------------------------
*/

CODE:

public class Residential extends Building

{

private int unitCount;//represents the number of occupied units

//------------------------------------------------------------------

// Constructor: Sets up this residential building using the specified

// information.

//-------------------------------------------------------------------

public Residential (String cOwner, String cAddr,String cPropID,

String cPropMgr,double rate)

{

super (cOwner,cAddr,cPropID,cPropMgr,rate);

unitCount = 1;

}

//------------------------------------------------------------------

// Adds the specified number of units to this building's count of

// occupied units

//-------------------------------------------------------------------

public void addUnits (int moreUnits)

{

unitCount += moreUnits;

}

//------------------------------------------------------------------

// Computes and returns the monthly for this residential building

//-------------------------------------------------------------------

public double monthlyFee()

{

double fee = rate * unitCount;
/*
* Modify the monthlyFee method for Residential buildings to calculate a complexity charge
* if the property has more than 40 occupied units that month. The complexity charge is calculated by
* multiplying the number of units over 40 by $10.
* Add the complexity charge to the monthlyFee before you return the result..
* */

fee=fee+(unitCount<=40?0:(unitCount-40)*10);

unitCount = 1;

return fee;

}

//------------------------------------------------------------------

// Returns information about this residential building as a string

//-------------------------------------------------------------------

public String toString()

{

String result = super.toString();

result += " Current number of occupied units: " +unitCount;

return result;

}

}

CODE:

abstract public class Property implements monthlyFee

{

protected String owner;

protected String address;

protected String propertyID;

//------------------------------------------------------------------

// Constructor:Sets up this property using the specified information

//------------------------------------------------------------------

public Property (String cOwner, String cLocation, String cPropID)

{

owner = cOwner;

address = cLocation;

propertyID = cPropID;

}

//-----------------------------------------------------------

// Returns a string including the basic property information

//-----------------------------------------------------------

public String toString()

{

String result = "Property Owner: " + owner + " ";

result += "Location: " + address + " ";

result += "Property ID: " +propertyID;

return result;

}

//---------------------------------------------------------------------

//Derived classes must define the fee method for each type of property

//---------------------------------------------------------------------

}

CODE:

public class VacantLot extends Property

{

//-------------------------------------------------------------------

//Constructor: Sets up this VacantLot using the specified information

//-------------------------------------------------------------------

public VacantLot (String cOwner, String cAddress, String cPropID)

{

super (cOwner, cAddress, cPropID);

}

//---------------------------------------------

//Returns a zero fee value for this VacantLot

//---------------------------------------------

public double monthlyFee()

{

return 0.0;

}

}

CODE:

public class Building extends Property

{

protected String propertyManager;

protected double rate;

//-----------------------------------------------------------------

// Constructor: Sets up the building with the specified information

//-----------------------------------------------------------------

public Building (String cOwner, String cAddr, String cPropID,

String cPropMgr,double rate)

{

super (cOwner, cAddr, cPropID);

propertyManager = cPropMgr;

this.rate = rate;

}

//--------------------------------------------------

// Returns information about a building as a string

//--------------------------------------------------

public String toString()

{

String result = super.toString();

result += " Property Manager: " + propertyManager;

return result;

}

//----------------------------------------------

// Returns the management fee for this building

//----------------------------------------------

public double monthlyFee()

{

return rate;

}

}

CODE:

public class Portfolio

{

private Property[] propertyList;

//---------------------------------------------

// Constructor: Sets up the list of properties

//---------------------------------------------

public Portfolio ()

{

propertyList = new Property[9];

propertyList[0] = new Commercial ("Jabba The Hutt", "123 Main Line","C-75","Boba Fett",2423.07);

propertyList[1] = new Building ("Donald Trump", "1 Trump Tower", "B-221", "Omarosa",1246.15);

propertyList[2] = new Building ("Tony Stark", "789 Off Rocker", "B-59", "Pepper Potts",1169.23);

propertyList[3] = new Residential ("Nick Fury", "678 Fifth Ave.", "R-154", "Phil Coulson", 20.55);

propertyList[4] = new VacantLot ("Jack Bauer", "987 Suds Blvd.", "Chloe");

propertyList[5] = new VacantLot ("Lone Ranger", "321 Duds Lane", "Tonto");
//a. Add 2 MobileHomeParks to the Portfolio array at positions 6 & 7. Make up information for the MobileHomeParks.

propertyList[6] =new MobileHomePark("My Name1", "My address1", "MYID1", "My Manager1", 30.24);

propertyList[7] =new MobileHomePark("My Name2", "My address2", "MYID2", "My Manager2", 74.28);

//b. Add 1 Residential building to the Portfolio array at position 8. Make up the information.

propertyList[8] = new Residential ("Mname resi", "My add resi.", "Resi ID", "Phil Coulson", 33.21);

//Add 15 units for the first mobile home park and 20 units for the second mobile home park.

((MobileHomePark)propertyList[6] ).addUnits(15);

((MobileHomePark)propertyList[7] ).addUnits(20);

//Add 49 units to the new Residential building.

((Residential)propertyList[8]).addUnits(49);


((Commercial)propertyList[0]).assessPercentRent(5000.00);

((Residential)propertyList[3]).addUnits(20);

}

//----------------------------------

// Calculates all management fees

//----------------------------------

public void assessFees ()

{

double amount;

for (int count=0;count < propertyList.length; count++)

{

System.out.println (propertyList[count]);

amount = propertyList[count].monthlyFee();//polymorphic

if (amount == 0.0)

System.out.println ("Public service to the community!");

else

System.out.println ("Total Fees: " + amount);

System.out.println ("------------------------------------------");

}

}

}

CODE:

public class Commercial extends Building

{

private double percentRent;

//------------------------------------------------------------------

// Constructor: Sets up this commercial building with the specified

// information.

//------------------------------------------------------------------

public Commercial (String cOwner, String cAddress, String cPropID,

String cPropMgr, double rate)

{

super (cOwner, cAddress, cPropID, cPropMgr, rate);

percentRent = 0; //percent of rent fee has not been determined

}

//-----------------------------------------------------

// Calculates the percentage rent fee

//-----------------------------------------------------

public void assessPercentRent (double sales)

{

percentRent = sales * 0.0275;

}

//----------------------------------------------------------------

// Computes and returns the total managemnt fee for a commercial

// building: monthly fee plus the percentage rent fee

//----------------------------------------------------------------

public double monthlyFee()

{

double fee = super.monthlyFee() + percentRent;

percentRent = 0;

return fee;

}

//----------------------------------------------------------------

// Returns information about this commercial building as a string

//----------------------------------------------------------------

public String toString()

{

String result = super.toString();

result += " Monthly Percentage Rent fee: " + percentRent;

return result;

}

}
CODE:

/*1.a. Remove the abstract monthlyFee method from the abstract Property class.
* Create a monthlyFee Interface with a single method that returns a double, is named monthlyFee, and receives no arguments.
* You will need to implement the interface just once, with the Property class (let inheritance take care overriding the method).
*/
public interface monthlyFee
{
   public double monthlyFee();
}


CODE:

public class MobileHomePark extends Residential
{
   /*The boss acquired 2 new Mobile Home Park properties to manage