Recall the code you wrote for Project 1, where you had a class called “HouseList”, which encapsulated an ArrayList of “House” objects that were created by reading in a “houses.txt” file. We are now going to write a program that reads the criteria to search for a house through a GUI, and then the list of houses available for sale will be searched to find a set of matching houses, and then randomly select one of these available houses and present it to the user for viewing.
In other words, you have to design a GUI screen that looks as follows (you will be working on the same lines as you did for Lab Exercise 7):
You should work of all the code you wrote for Project 1, but the additional specifications for this project are as follows:
Initially, when the blank screen comes up, the first (left) button, with the label “Find my dream house!” is clickable (live), and the second (right) button, with the label “Not my dream – find me another!” is NOT clickable (not live). In other words, nothing should happen if the user clicks it.
When the user enters the values for the various criteria variables into the screen above, and then clicks the “Find my dream house!” button, the text field with the label “Chosen Home” should be populated with the address of one of the homes that match the entered criteria, chosen randomly (see the “Helpful Hints” section below) from the matching set of available houses. At this point, the second (right) button, the one with the label “Not my dream – find me another!” should become clickable (live), and the button with the label “Find my dream house!” should not be clickable.
PLEASE NOTE: If the user leaves any of the criteria text fields BLANK and clicks the button with the label “Find my dream house!”, then the program should still function correctly (not crash!). The program should assume that the value entered into the field is 0 (zero) if the field left blank was one of the “minimum fields” (price, area, beds) and it should assume that the value entered into the field is Integer.MAX_VALUE if the field left blank was one of the “maximum fields” (again, for price, area or number of bedrooms). Based on these assumptions, the program should find a list of matching available houses, and then randomly select one house’s address to show.
Once the second (right) button with the label “Not my dream – find me another!” becomes live and clickable, and the user clicks that button, the program should go through the list of available houses matching the entered criteria and select another house from this list randomly. It should then show the address of this house in the “Chosen Home” text field. Care must be taken to ensure that the newly shown address is NOT the same as any address that has already been shown to the user. In other words, you must keep track of a house the user has already seen, and be sure to show another. If there are no unseen available houses left in the list matching the entered criteria, then show the text “No more available houses” in the “Chosen Home” text field.
When the user clicks the “Reset” button, the program essentially starts all over again. In other words, all the text fields on the GUI screen above are cleared. Also, any records your program may have kept – such as the ArrayList of matching houses, and any record of already seen houses (as described in point (4) above) – need to be cleared, and restored to the state that these variables were in when the program first started up (NOTE: the list of available houses read in from the “houses.txt” file, of course, remains unchanged). Also, at this point, the first (left) button with the label “Find my dream house!” should be live and clickable, and the second (right) button with the label “Not my dream – find me another!” should not be live and clickable – i.e., again, things should be just as they were when the program first started up. At this point, the user can enter new criteria, click the first (left) button and “go” again as described above.
Contact us for this JavaFX assignment Solutions by Codersarts Specialist who can help you mentor and guide for such JavaFX assignments.If you have project or assignment files CONTACT US NOW