Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; public class ManagementCompanyTest { Property p1 ,p2,p3,p4,p5; ManagementCompany m ; @Before public void setUp() throws Exception
import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; public class ManagementCompanyTest { Property p1 ,p2,p3,p4,p5; ManagementCompany m ; @Before public void setUp() throws Exception { p1 = new Property ("Belmar", "Silver Spring", 1200.45, "John Smith"); p2 = new Property ("Camden Lakeway", "Rockville", 2450, "Ann Taylor"); p3 = new Property ("Hamptons", "Rockville", 1250, "Rick Steves"); m= new ManagementCompany("Alliance", "1235",6); m.addProperty(p1); m.addProperty(p2); m.addProperty(p3); } @After public void tearDown() { p1=p2=p3=null; m=null; } @Test public void testAddProperty() { p4 = new Property ("Mallory Square", "Wheaton", 1000, "Abbey McDonald"); p5 = new Property ("Lakewood", "Rockville", 3000, "Alex Tan"); assertEquals(m.addProperty(p4),3,0); assertEquals(m.addProperty(p5),4,0); assertEquals(m.addProperty(p1),-1,0); //exceeds the size of the array and can not be added, add property should return -1 } @Test public void testMaxPropertyRentIndex() { assertEquals(m.maxPropertyRentIndex(),1,0); } @Test public void testTotalRent() { assertEquals(m.totalRent(),4900.45,0); } }
public class PropertyMgmDriverNoGui { public static void main(String[] args) { //Create property objects Property p1 = new Property ("Belmar", "Silver Spring", 1200, "John Smith"); Property p2 = new Property ("Camden Lakeway", "Rockville", 5000, "Ann Taylor"); Property p3 = new Property ("Hamptons", "Rockville", 1250, "Rick Steves"); Property p4 = new Property ("Mallory Square", "Wheaton", 1000, "Abbey McDonald"); Property p5 = new Property ("Lakewood", "Rockville", 3000, "Alex Tan"); //Create management company object ManagementCompany m = new ManagementCompany("Alliance", "1235",6); //Add the properties to the list of properties of the management company System.out.println(m.addProperty(p1)); //Should add the property and display the index where the property is added to the array System.out.println(m.addProperty(p2)); System.out.println(m.addProperty(p3)); System.out.println(m.addProperty(p4)); System.out.println(m.addProperty(p5)); System.out.println(m.addProperty(p5)); //it should display -1 to indicate the property is not added to the array //Display the information of the property that has the maximum rent amount System.out.println("The property with the highest rent: " + m.displayPropertyAtIndex(m.maxPropertyRentIndex())); //Display the total rent of the properties within the management company System.out.println(" Total Rent of the properties: "+m.totalRent()+ " "); System.out.println(m); //List the information of all the properties and the total management fee } }
Operation When driver-driven application starts (provided), it creates a property management company and some rental properties, adds them to the list of the properties managed by the property management company, and prints information about the properties using the property manager's methods When the GUI-driven application starts, a window should be created as in the following screen shots which allows the user to enter data for management company and its rental properties. The driver and the GUI will both use the same classes for their operation. The TUnit test class also tests the same classes as the driver and the GUI Specifications Data Element-Property The class Property will contain: 1. stance variables for property's name, city, rent amount and owner's name 2. toString method to represent a Property object. Refer to JavaDoc for the data types 3. Constructors (a copy constructor and a parameterized constructor) and getter and setter methods Data Structure An Array ofProperty objects to hold the properties that the management company handles Data Manager 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 management company's name, tax Id, management fee, MAX PROPERTY (a constant set to 5) and an array of size MAx PROPERTY of Property objects 2. Method managementCompany Constructor-pass in arguments for the name of the management company, tax Id and management Free to create a ManagementCompany object. 3- Method addProperty-Pass in a parameter of type Property object. It will add the Property object to the properties array. It will return the index of the array where the property is added or -1 ifthe array is full. 4. Method totalRent- Returns the total rent of the properties in the properties array 5. Method maxPropertyIndex-returns the index of the property within the properties array that has the highest rent amount. For simplicity assume that each "Property" object's rent amount is different. 6. Method displayPropertyAtIndex- pass in the index of the Property object in the properties array and return the string representation of the property You may need additional methods to include in this class User Interface Your graphical user interface or the provided PropertyMgmD are the only riverNoGuijava classes that interact with the user. The GUI will have the general structure of the following screen shots Operation When driver-driven application starts (provided), it creates a property management company and some rental properties, adds them to the list of the properties managed by the property management company, and prints information about the properties using the property manager's methods When the GUI-driven application starts, a window should be created as in the following screen shots which allows the user to enter data for management company and its rental properties. The driver and the GUI will both use the same classes for their operation. The TUnit test class also tests the same classes as the driver and the GUI Specifications Data Element-Property The class Property will contain: 1. stance variables for property's name, city, rent amount and owner's name 2. toString method to represent a Property object. Refer to JavaDoc for the data types 3. Constructors (a copy constructor and a parameterized constructor) and getter and setter methods Data Structure An Array ofProperty objects to hold the properties that the management company handles Data Manager 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 management company's name, tax Id, management fee, MAX PROPERTY (a constant set to 5) and an array of size MAx PROPERTY of Property objects 2. Method managementCompany Constructor-pass in arguments for the name of the management company, tax Id and management Free to create a ManagementCompany object. 3- Method addProperty-Pass in a parameter of type Property object. It will add the Property object to the properties array. It will return the index of the array where the property is added or -1 ifthe array is full. 4. Method totalRent- Returns the total rent of the properties in the properties array 5. Method maxPropertyIndex-returns the index of the property within the properties array that has the highest rent amount. For simplicity assume that each "Property" object's rent amount is different. 6. Method displayPropertyAtIndex- pass in the index of the Property object in the properties array and return the string representation of the property You may need additional methods to include in this class User Interface Your graphical user interface or the provided PropertyMgmD are the only riverNoGuijava classes that interact with the user. The GUI will have the general structure of the following screen shots
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started