In: Computer Science
A property management company manages individual properties they will build to rent, and charges them a management fee as the percentages of the monthly rental amount. The properties cannot overlap each other, and each property must be within the limits of the management company’s plot. Write an application that lets the user create a management company and add the properties managed by the company to its list. Assume the maximum number of properties handled by the company is 5
Concepts tested: • Aggregation • Passing object to method • Array Structure • Objects as elements of the Array • Processing array elements • Copy Constructor • Junit test
Classes:
The class Property will contain: 1. Instance variables for property name, city, rental amount, owner, and plot. Refer to JavaDoc for the data types of each instance variable. 2. toString method to represent a Property object. 3. Constructors (a copy constructor and parameterized constructor) and getter and setter methods. One parameterized constructor will have parameters for property name, city, rent amount, owner, x and y location of the upper left corner of the property’s plot, the plot’s width and its depth. A second constructor will only have parameters for name, city, rental amount, and owner, and will generate a default x, y, width, and depth.
The class Plot will contain: 1. Instance variables to represent the x and y coordinates of the upper left corner of the location, and depth and width to represent the vertical and horizontal extents of the plot. 2. A toString method to represent a Plot object 3. Constructors (a no-arg constructor, a copy constructor and a parameterized constructor) 4. A method named overlaps that takes a Plot instance and determines if it is overlapped by the current plot. 5. A method named encompasses that takes a Plot instance and determines if the current plot contains it. Note that the determination should be inclusive, in other words, if an edge lies on the edge of the current plot, this is acceptable. This class should not have any output functionality (e.g., no GUI-related or printing related functionality), but should take input, operate on the data structure, and return values or set variables that may be accessed with getters.
The class ManagementCompany will contain the following methods in addition to get and set methods: 1. Instance variables of name, tax Id, management fee, MAX_PROPERTY (a constant set to 5) and an array of size MAX_PROPERTY of Property objects. 2. Constructor managementCompany – pass in arguments for the name of the management company, tax Id and management Fee, along with the X, Y, width, and depth of the overall plot that will be subdivided into plots for each property. A ManagementCompany object will be created. 3. Constructor managementCompany – pass in arguments for the name of the management company, tax Id and management Fee to create a ManagementCompany object. A default plot will be created with programmer-determined values into which to subdivide the plots for each property. 4. Method addProperty (3 versions) – a. Pass in a parameter of type Property object. It will add the Property object to the properties array. b. Pass in four parameters of types: i. String propertyName, ii. String city, iii. double rent, and iv. String ownerName. c. Pass in eight parameters of types: i. String propertyName, ii. String city, iii. double rent, iv. String ownerName, v. int x, vi. int y, vii. int width, and viii. int depth. d. It returns -1 if the array is full, -2 if property is null, -3 if the plot is not contained by the MgmtCompany’s plot, -4 if the plot overlaps any other property, or the index in the array where the property was added successfully. 5. Method totalRent– Returns the total rent of the properties in the properties array. 6. Method maxPropertyRent-returns the String representation of the property within the properties array that has the highest fee amount. For simplicity assume that each "Property" object's fee amount is different. 7. Method maxPropertyIndex- returns the index of the property within the properties array that has the highest fee amount. This method will be private. 8. Method displayPropertyAtIndex– pass in the index of the Property object in the properties array and return the string representation of the property. This method will be private.
Driver class – (provided)
GUI Driver class – (provided)
JUnit Test (provided)
Write a Data Element Class named Property that has fields to hold the property name, the city where the property is located, the rent amount, the owner's name, and the Plot to be occupied by the property, along with getters and setters to access and set these fields. Write a parameterized constructor (i.e., takes values for the fields as parameters) and a copy constructor (takes a Property object as the parameter). Follow the Javadoc file provided.
Write a Data Element Class named Plot that has fields specifying the X and Y location of the upper left corner of each Plot and a depth and width of each Plot. Notice that the X,Y location is at the upper left, not as in normal Cartesian coordinates, due to the grid system adopted by computer monitors. A driver class is provided that creates rental properties to test the property manager. A Graphical User Interface is provided using JavaFX which duplicates this driver’s functionality. You are not required to read in any data, but the GUI will allow you to enter the property management company and each property by hand. A directory of images is provided. Be sure to place the “images” directory (provided) inside the “src” directory in Eclipse. Operation When driver-driven application starts, a driver class (provided) creates a management company, creates rental properties, adds them to the property manager, and prints information about the properties using the property manager’s methods. When the GUI-driven application starts (provided), a window is created as in the following screen shots which allows the user to enter applicable data and display the resulting property. The driver and the GUI will both use the same classes and methods for their operation. The JUnit test class also tests the same classes as the driver and the GUI.
Can someone please help me with the Plot class?
import java.util.Arrays; public class ManagementCompany { private final int MAX_PROPERTY = 5; private double mgmFeePer; private String name; private Property[] properties; private String taxID; private int MAX_WIDTH = 10,count=0; private int MAX_DEPTH = 10; private Plot plot ; /** * A No-Arg Constructor that creates a Management Company object. */ public ManagementCompany() { properties = new Property[MAX_PROPERTY]; this.name= ""; this.taxID = ""; this.plot = new Plot (0,0,MAX_WIDTH,MAX_DEPTH ); } /** * A management company parameterized constructor with a default company plot. * @param name name of the company * @param taxID taxID of the property * @param mgmFeePer management fee */ public ManagementCompany(String name, String taxID, double mgmFeePer) { properties = new Property[MAX_PROPERTY]; this.name = name; this.taxID = taxID; this.mgmFeePer = mgmFeePer; this.plot = new Plot (0,0,MAX_WIDTH,MAX_DEPTH ); } /** * Copy constructor creates a ManagementCompany object using another ManagementComapany object.. * @param otherCompany otherCompany is an object that is a copy */ public ManagementCompany(ManagementCompany otherCompany) { properties = new Property[MAX_PROPERTY]; name = otherCompany.name; taxID = otherCompany.taxID; mgmFeePer = otherCompany.mgmFeePer; plot = otherCompany.plot; } /** * A management company parameterized constructor that sets the plot for the company. * @param name * @param taxID * @param mgmFeePer * @param x * @param y * @param width * @param depth */ public ManagementCompany(String name, String taxID, double mgmFeePer,int x, int y, int width, int depth) { properties = new Property[MAX_PROPERTY]; this.name = name; this.taxID = taxID; this.mgmFeePer = mgmFeePer; this.plot = new Plot( x, y, width, depth); } /** * A get method that returns the size of properties array. * @return MAX_PROPERTY size of the array. */ public int getMAX_PROPERTY() { return MAX_PROPERTY; } /** * Adds a an already created property to the array. * @param property * @return */ public int addProperty(Property property) { int i; for( i =0; i < count; i++) { if(properties[i].getPlot().overlaps(property.getPlot())) return -4; } // if(property!=null) // { // properties[count]=property; // count++; // return count; // } if(count == MAX_PROPERTY) { return -1; } if(property== null) { return -2; } if(this.plot.encompasses(property.getPlot()) ) { return -3; } else { properties[count]=property; count++; return count; } } /** * A method that adds the property with four arguments and a default plot to the array. * @param name * @param city * @param rent * @param owner * @return */ public int addProperty(String name, String city, double rent, String owner){ //create a property object. Property property = new Property(name, city, rent, owner, 0, 0, 1,1); //adds the property object to properties array. properties[count] = property; count++; int i; for( i =0; i < count; i++) { if(properties[i].getPlot().overlaps(property.getPlot())) return -4; } if(count == MAX_PROPERTY) { return -1; } if(this.plot.encompasses(property.getPlot())) { //else if() return -3; } else { properties[count]=property; count++; return count; } } /** * An add property that has all the parameters for the property and the plot. * @param name * @param city * @param rent * @param owner * @param x * @param y * @param width * @param depth * @return */ public int addProperty(String name, String city,double rent, String owner, int x, int y, int width,int depth) { int i; //Creates a property object that calls the constructor of Plot. Property property = new Property(name, city, rent, owner, x, y,width, depth); //Adds the property object to the properties array. properties[count] = property; // create a plot //Plot plot = new Plot(x,y, width, depth); // Question is this the correct way of checking if the plot overlaps with the other property plots????? for( i =0; i < count; i++) { if(properties[i].getPlot().overlaps(property.getPlot())) return -4; } if(count == MAX_PROPERTY) { return -1; }else if(this.plot.encompasses(property.getPlot()) ) { return -3; } else { properties[count]=property; count++; return count; } } /** * A method that adds up all the amounts of rent. * not finished yet. */ public double totalRent() { double totalRent =0.0 ; for(int i = 0; i < count; i++) { if(properties[i] != null) { totalRent += properties[i].getRentAmount(); } } return totalRent; } public double maxPropertyRent() { double maxRentAmount = 0.0; maxRentAmount = properties[maxPropertyRentIndex()].getRentAmount(); return maxRentAmount; } public int maxPropertyRentIndex() { int indexOFMaxRent=0; for (int i =0; i < count; i++) { if(properties[i] != null) { if(properties[indexOFMaxRent].getRentAmount() < properties[i].getRentAmount()) { indexOFMaxRent = i; } } } return indexOFMaxRent; } public String displayPropertyAtIndex(int i) { String str = ""; if(properties[i] != null) { str= ("Owner: " + properties[i].getOwner() + "City: " + properties[i].getCity() + "Property Name: " + properties[i].getPropertyName() + "Rent Amount: " + properties[i].getRentAmount() + "Plot: " + properties[i].getPlot()); } return str; } public String toString() { String printContent = ""; System.out.println("List of the properties for Alliance, taxID: " + taxID ); System.out.println("__________________________________________________"); for(int i = 0; i < count; i++) { if(properties[i] != null) printContent = (" Property Name: " + properties[i].getPropertyName() +"\n" + " Located in: " + properties[i].getCity() + "\n" + " Belonging to: " + properties[i].getOwner() + "\n" + " Rent Amount: " + properties[i].getRentAmount()); } System.out.println("__________________________________________________"); System.out.println("Total management Fee: " + mgmFeePer); return printContent; } }