Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 - Defining and unit testing a simple property management systemThe classes for this question are shown in the UML diagram below. You should
Question Defining and unit testing a simple property management systemThe classes for this question are shown in the UML diagram below. You should write the code that implements this structure.Place your code in the Question package within the srcmainjava folder.The question provides the learning experience in iterating through a list of properties, and each property consists of a map of rooms and their associated tenants. This question addresses the following functionality from the problem denition: A I, Q RNote: This question deals only with shared houses.Q UMLWriting Java CodeDene a well formatted Room class. A room object consists of a price eld and a simple getPrice method not on the UML diagram but could be helpful which returns the rooms price without being formatted in any way:Dene a well formatted Tenant class. A tenant object consists of four elds; a forename, surname,age, type. The Tenant is an implementation of ITenant and provides the implementation of the interface methods including a getName method that returns the tenants full name as follows:Stella KazamiaDene a well formatted House class that handles a collection of rooms and their associated tenants. The House class provides a toString method which returns the formatted house as: The Chase, Guildford GUUB bedroom house : availableNote that there are two methods in the House class that are dened with a dierent visibility. The methods from the House class diagram that have interesting functionality to implement are the following:getAvailableRooms: This method checks whether or not there are any tenants in any of the rooms and returns the number of rooms that are not occupied. If there are no available rooms, then the value is returned.getPrice: This method returns the price of that property by calculating the sum of all the room prices. For example, for a bedroom house of which both rooms are per calendar month each, the getPrice method will return occupy: The system allows a tenant to be assigned to a room, given that the house is not listed as Unavailable. All successful tenants are then added in the map with their associated rooms. Additional validations and exceptions should be considered to ensure that only valid parameters are parsed.Dene a well formatted PropertyManagement class which consists of a list of houses. Note that the display method should not contain any System.out.println statements. This method needs to return the appropriate display string so that it can be tested against using an assert statement.Perform Correct ValidationExample: Look at the code in the House and PropertyManagement class and ensure your classes throw the necessary exceptions, otherwise the tests will fail. In particular, this means that a House or a PropertyManagement object cannot be created with invalid parameters.Important Note: Valid postcodes includes those within Guildford as this is a letting agency based on Guildford. These include postcodes that follow the following structure: XXXX or XXXX where X represents a capital letter and represents a numeric value. A space may be included after the first three characters or omitted. Both should be accepted. As the postcode is located in Guildford the first initial characters should be GU with no restrictions on what the digits or last two characters should be In the examples above you would have seen that a valid postcode could be GUUBAfter completing the code for each class, test it against the test classes provided for this question. You do not have to wait until you have completed all the classes before running the tests. Test as you write code.Remember that if you see any errors in the test classes, this is because you have probably misread the UML class diagram or instructions, or might have forgotten to change the package and import statements.The format of the test classes will give you an insight into how to write the correct code. Make sure that you read them to understand what the expected functionality is do not just run them.As you may have observed, JUnit files have been provided with a total of test methods. These methods test the minimum required functionality of your code. Additional tests are to run against your code after submitting your final code. This is to ensure that no hardcoded statements have been included nor any incorrect functionality. Make sure that you read the specification carefully, and the additional information provided in the 'Writing Java Code' section.Important Note: Some classes do not have corresponding JUnit files.Writing JUnit TestsYou have also been provided with the unit test classes for the Room, House and PropertyManagement,House and Room classes.Dene a new test class called TenantTest with appropriate test methods and place this in the correct folder within the Question test package to unit test the Tenant class.Make sure that a Tenant object can only be created if valid parameters are parsed. This includes a valid age, forename, surname and type. For example, a NullPointerException should be raised if any of these parameters are left empty, and an IllegalArgumentException if these parameters do not meet the required format.
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