Answered step by step
Verified Expert Solution
Link Copied!

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 1- 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_1 package within the src/main/java 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.Q1 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:800.0Dene 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:1 The Chase, Guildford GU27UB (2 bedroom house :1 available)Note 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 0 is returned.getPrice: This method returns the price of that property by calculating the sum of all the room prices. For example, for a 2-bedroom house of which both rooms are 900 per calendar month each, the getPrice method will return 1800.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: XX00XX or XX00XX, where X represents a capital letter and 0 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 GU27UB.After 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, 3 JUnit files have been provided with a total of 11 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 hard-coded 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_1 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

Is concurrent scheduling the same as double booking

Answered: 1 week ago

Question

What are the Lodoacetamide Effects on Active Site Amino Acids?

Answered: 1 week ago