Question
Java You have been hired by the company Find Me A House Fast. Your job is to produce a list of real-estate listings that meet
Java
You have been hired by the company Find Me A House Fast. Your job is to produce a list of real-estate listings that meet a client's criterion. You have a list of real-estate listings from the companies: Century 21, ReMax, Mc Enearney and Long & Foster. The home buyer first chooses the real-estate companies he wishes to use. The home buyer then can choose one of the following criteria: Style, Number of Bedrooms, Lot Size, Age, Price, Distance from Work, and Jurisdiction. Given a criterion and the list of real-estate companies, your job is to create a list of home listings from the chosen companies that satisfy the chosen criterion.You have a list of home listings from each real-estate company from which to choose.
what I have so far
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Scanner;
public class CreateHomeListMain { public static void main(String[] args) { // *** these lines print to a file and shows where to put listing files PrintWriter outStream = TextFileIO.createTextWrite("out.txt"); outStream.println("hi"); System.out.println("hi"); outStream.close(); RealEstateAgent myAgent = new RealEstateAgent(); Scanner scan = new Scanner(System.in); System.out.println("I make lists."); System.out.println("Would you like to create a list?"); System.out.println("Enter yes or no."); String choice = scan.nextLine(); while (choice.equalsIgnoreCase("yes")) { String theHomeList = myAgent.listingsChosen(); System.out.println(theHomeList); System.out.println("Would you like to create a new list"); System.out.println("Enter yes or no."); choice = scan.nextLine(); } // while System.out.println("Thank you for creating lists.");
} }
import java.text.NumberFormat; import java.util.ArrayList; import java.util.Scanner;
public class RealEstateAgent // *** this is the largest class { // *** ArrayLists that I used. private ArrayList
public RealEstateAgent() { // Create real-estate companies here. // Give them a name and pass in their text file. // Here is the code. century21 = new Agency("Century 21", "century21.txt"); reMax = new Agency("ReMax", "remax.txt"); mcEnearney = new Agency("McEnearney", "mcenearney.txt"); longAndFoster = new Agency("LongAndFoster", "longandfoster.txt");
}
public String listingsChosen() { getAgenciesForTheExhibition();//*** this is an ArrayList //*** I read a String and used a Scanner instance to scan a string //*** for the integers integers. See handout for an example of this. homeCriterion = pickHomeCriterion(); switch (homeCriterion) { case 1:// Style int style = getStyle(); finalArrayListOfRealEstateListings = style(style, agencyArray); break; default: System.out.println("bad topic Selection choice " + homeCriterion); System.exit(0); }// switch // *** I have a method that creates a string of the agencies used. // *** I have a method that takes the final list of homes // *** and puts them in a string that is returned.
public int getStyle() { }
public ArrayList
// *** For each criteria there are similar pairs of methods. // *** Work on each pair one pair at a time and make them // *** work before you do the next pair. }
import java.util.ArrayList; import java.util.Scanner;
public class Agency { private String agency; private ArrayList
public Agency(String agency, String agencyFile) { // *** Constructor reads its file into an ArrayList // *** dont forget to close the Scanner // *** Here is the code to read a file this.agency = agency; Scanner scanAgencyFile = TextFileIO.createTextRead(agencyFile); readFile(scanAgencyFile); scanAgencyFile.close(); }
public void readFile(Scanner read) { // *** The first number in the file is the number of listings. // *** This sets the for loop // *** A RealEstateListing can read itself. }
public ArrayList
public class RealEstateListing { // *** instance variables go here.
public void readRealEstateListing(Scanner read) { // *** Read a listing. // *** Set the instance variables. } // *** I have a complete set of getters and setters created by Eclipse
public String toString() {
} }
import java.util.Scanner; import java.io.*;
public class TextFileIO { public static void main(String[] args) { String fileName = "textFile.txt"; int x = 3; String line = null; int count; Scanner scan = new Scanner(System.in); PrintWriter textStream =TextFileIO.createTextWrite(fileName); System.out.println("Enter 4 lines of text:"); for (count = 1; count <= 4; count++) { line = scan.nextLine(); textStream.println(count + " " + line); } textStream.close( ); // did not require error handling System.out.println("Those lines were written to " + fileName); System.out.println(); System.out.print("Now we will read them from " + fileName + " using the "); System.out.println("Scanner class." ); Scanner scanFile = TextFileIO.createTextRead(fileName);// scan a file for (count = 1; count <= 4; count++) { count = scanFile.nextInt(); line = scanFile.nextLine(); System.out.println(count + line); } scanFile.close();
}
public static PrintWriter createTextWrite(String S) { PrintWriter TStream = null; try { TStream = new PrintWriter(new FileOutputStream(S)); } catch (FileNotFoundException e) { System.out.println("Error opening the file in createTextWrite"); System.exit(0); } return TStream; }
public static Scanner createTextRead(String S) { Scanner textFile = null; try { textFile = new Scanner(new File(S)); } catch (FileNotFoundException e) { System.out.println("File not found"); System.out.println("or could not be opened."); } return textFile; }
}
remax.txt
20 1 Split Level 4 2.0 1.9 14 359.0 8.5 Fairfax 2 Condominium 32 2 0 11 359 13 Falls Church 3 Colonial 3 2.5 1.1 17 459 8 Alexandria 4 Georgian 3 3 1.5 24 356 11 Fairfax 5 Townhouse 2 1 0 16 296 7 Falls Church 6 Rambler 4 3 1.2 17 349 13 Fairfax 7 Townhouse 2 2 0 19 179 15 Alexandria 8 Split Level 3 2 .2 14 249 1 Fairfax 9 Split Level 3 2 .2 16 329 12 Alexandria 10 Townhouse 3 1 0 4 199 16 Falls Church 11 Rambler 3 2 1.2 15 349 8.5 Fairfax 12 Condominium 2 2 0 17 149 14.5 Alexandria 13 Split Level 4 2 1.75 14 389 7 Fairfax 14 Colonial 3 2.5 1.4 19 379 10 Fairfax 15 Cape Cod 3 2.5 2.1 14 369 7.5 Alexandria 16 Georgian 3 2.5 2.2 12 359 15 Falls Church 17 Split Level 4 2 2.4 10 358 12 Fairfax 18 Condominium 3 2.5 0 11 219 16 Falls Church 19 Georgian 3 2 1.4 18 489 12 Fairfax 20 Townhouse 3 2 0 2 359 5 Alexandria
rest the text files are in this format
Output sample:
I am a Real Estate Agent. I can create a list of homes for sale. Would you like to create such a list? Enter yes or no. yes For this list of homes which real-estate agencies would you like the home listings drawn from? Please enter their numbers on one line 1) Century 21 2) ReMax 3) McEnearney 4) Long & Foster 1 2 3 4 Please choose a home criteria and enter its number. 1) Style 2) Number Of Bedrooms 3) Number Of Bathrooms 4) Lot Size 5) Age 6) Price 7) Distance From Work 8) Jurisdiction 8 Please choose the jurisdiction and enter its number. 1) Alexandria 2) Arlington 3) Fairfax 4) Falls Church 5) District of Columbia 3 The list of realstate agencies used are: Century 21 ReMax McEnearney Long & Foster The jurisdiction of the house is Fairfax. 1 )Style: Colonial Bedrooms: 4 Bathrooms: 2.0 Lot size: 2.9 Square acre Age: 4 Price: $350,000.00 Distance: 6.5 Jurisdiction: Fairfax 2 )Style: Colonial Bedrooms: 3 Bathrooms: 2.0 Lot size: 2.0 Square acre Age: 4 Price: $450,000.00 Distance: 16.0 Jurisdiction: Fairfax 3 )Style: Split Level Bedrooms: 4 Bathrooms: 3.0 Lot size: 2.0 Square acre Age: 11 Price: $300,000.00 Distance: 2.0 Jurisdiction: Fairfax 4 )Style: Townhouse Bedrooms: 3 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 14 Price: $99,000.00 Distance: 6.0 Jurisdiction: Fairfax 5 )Style: Condominium Bedrooms: 4 Bathrooms: 3.0 Lot size: 0.0 Square acre Age: 7 Price: $249,000.00 Distance: 4.5 Jurisdiction: Fairfax 6 )Style: Cape Cod Bedrooms: 4 Bathrooms: 2.5 Lot size: 0.1 Square acre Age: 12 Price: $269,000.00 Distance: 3.5 Jurisdiction: Fairfax 7 )Style: Condominium Bedrooms: 1 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 14 Price: $105,000.00 Distance: 6.0 Jurisdiction: Fairfax 8 )Style: Colonial Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.4 Square acre Age: 8 Price: $389,000.00 Distance: 6.0 Jurisdiction: Fairfax 9 )Style: Townhouse Bedrooms: 2 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 12 Price: $159,000.00 Distance: 15.0 Jurisdiction: Fairfax 10)Style: Split Level Bedrooms: 4 Bathrooms: 2.0 Lot size: 1.9 Square acre Age: 14 Price: $359,000.00 Distance: 8.5 Jurisdiction: Fairfax 11)Style: Georgian Bedrooms: 3 Bathrooms: 3.0 Lot size: 1.5 Square acre Age: 24 Price: $356,000.00 Distance: 11.0 Jurisdiction: Fairfax 12)Style: Rambler Bedrooms: 4 Bathrooms: 3.0 Lot size: 1.2 Square acre Age: 17 Price: $349,000.00 Distance: 13.0 Jurisdiction: Fairfax 13)Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.2 Square acre Age: 14 Price: $249,000.00 Distance: 1.0 Jurisdiction: Fairfax 14)Style: Rambler Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.2 Square acre Age: 15 Price: $349,000.00 Distance: 8.5 Jurisdiction: Fairfax 15)Style: Split Level Bedrooms: 4 Bathrooms: 2.0 Lot size: 1.75 Square acre Age: 14 Price: $389,000.00 Distance: 7.0 Jurisdiction: Fairfax 16)Style: Colonial Bedrooms: 3 Bathrooms: 2.5 Lot size: 1.4 Square acre Age: 19 Price: $379,000.00 Distance: 10.0 Jurisdiction: Fairfax 17)Style: Split Level Bedrooms: 4 Bathrooms: 2.0 Lot size: 2.4 Square acre Age: 10 Price: $358,000.00 Distance: 12.0 Jurisdiction: Fairfax 18)Style: Georgian Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.4 Square acre Age: 18 Price: $489,000.00 Distance: 12.0 Jurisdiction: Fairfax 19)Style: Condominium Bedrooms: 2 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 13 Price: $259,000.00 Distance: 13.0 Jurisdiction: Fairfax 20)Style: Georgian Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.2 Square acre Age: 2 Price: $350,000.00 Distance: 14.0 Jurisdiction: Fairfax 21)Style: Colonial Bedrooms: 4 Bathrooms: 2.0 Lot size: 1.4 Square acre Age: 15 Price: $458,000.00 Distance: 11.0 Jurisdiction: Fairfax 22)Style: Colonial Bedrooms: 4 Bathrooms: 2.0 Lot size: 3.4 Square acre Age: 18 Price: $438,000.00 Distance: 8.0 Jurisdiction: Fairfax 23)Style: Townhouse Bedrooms: 2 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 12 Price: $199,000.00 Distance: 16.0 Jurisdiction: Fairfax 24)Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.75 Square acre Age: 7 Price: $249,000.00 Distance: 5.8 Jurisdiction: Fairfax 25)Style: Cape Cod Bedrooms: 3 Bathrooms: 2.5 Lot size: 1.1 Square acre Age: 2 Price: $369,000.00 Distance: 7.5 Jurisdiction: Fairfax Would you like to create a new set of home listings? Enter yes or no. yes For this list of homes which real-estate agencies would you like the home listings drawn from? Please enter their numbers on one line 1) Century 21 2) ReMax 3) McEnearney 4) Long & Foster 1 2 3 Please choose a home criteria and enter its number. 1) Style 2) Number Of Bedrooms 3) Number Of Bathrooms 4) Lot Size 5) Age 6) Price 7) Distance From Work 8) Jurisdiction 2 Please enter the number of bedrooms 3 The list of realstate agencies used are: Century 21 ReMax McEnearney The number of bedrooms are 3. 1 )Style: Townhouse Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 6 Price: $150,000.00 Distance: 6.0 Jurisdiction: District of Columbia 2 )Style: Townhouse Bedrooms: 3 Bathrooms: 3.0 Lot size: 0.0 Square acre Age: 9 Price: $250,000.00 Distance: 11.0 Jurisdiction: Arlington 3 )Style: Colonial Bedrooms: 3 Bathrooms: 2.0 Lot size: 2.0 Square acre Age: 4 Price: $450,000.00 Distance: 16.0 Jurisdiction: Fairfax 4 )Style: Townhouse Bedrooms: 3 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 14 Price: $99,000.00 Distance: 6.0 Jurisdiction: Fairfax 5 )Style: Rambler Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.2 Square acre Age: 13 Price: $249,000.00 Distance: 6.5 Jurisdiction: Alexandria 6 )Style: Georgian Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.2 Square acre Age: 20 Price: $359,000.00 Distance: 11.0 Jurisdiction: Arlington 7 )Style: Colonial Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.4 Square acre Age: 8 Price: $389,000.00 Distance: 6.0 Jurisdiction: Fairfax 8 )Style: Colonial Bedrooms: 3 Bathrooms: 2.5 Lot size: 1.1 Square acre Age: 17 Price: $459,000.00 Distance: 8.0 Jurisdiction: Alexandria 9 )Style: Georgian Bedrooms: 3 Bathrooms: 3.0 Lot size: 1.5 Square acre Age: 24 Price: $356,000.00 Distance: 11.0 Jurisdiction: Fairfax 10)Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.2 Square acre Age: 14 Price: $249,000.00 Distance: 1.0 Jurisdiction: Fairfax 11)Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.2 Square acre Age: 16 Price: $329,000.00 Distance: 12.0 Jurisdiction: Alexandria 12)Style: Townhouse Bedrooms: 3 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 4 Price: $199,000.00 Distance: 16.0 Jurisdiction: Falls Church 13)Style: Rambler Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.2 Square acre Age: 15 Price: $349,000.00 Distance: 8.5 Jurisdiction: Fairfax 14)Style: Colonial Bedrooms: 3 Bathrooms: 2.5 Lot size: 1.4 Square acre Age: 19 Price: $379,000.00 Distance: 10.0 Jurisdiction: Fairfax 15)Style: Cape Cod Bedrooms: 3 Bathrooms: 2.5 Lot size: 2.1 Square acre Age: 14 Price: $369,000.00 Distance: 7.5 Jurisdiction: Alexandria 16)Style: Georgian Bedrooms: 3 Bathrooms: 2.5 Lot size: 2.2 Square acre Age: 12 Price: $359,000.00 Distance: 15.0 Jurisdiction: Falls Church 17)Style: Condominium Bedrooms: 3 Bathrooms: 2.5 Lot size: 0.0 Square acre Age: 11 Price: $219,000.00 Distance: 16.0 Jurisdiction: Falls Church 18)Style: Georgian Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.4 Square acre Age: 18 Price: $489,000.00 Distance: 12.0 Jurisdiction: Fairfax 19)Style: Townhouse Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 2 Price: $359,000.00 Distance: 5.0 Jurisdiction: Alexandria 20)Style: Colonial Bedrooms: 3 Bathrooms: 2.5 Lot size: 0.4 Square acre Age: 17 Price: $359,000.00 Distance: 6.0 Jurisdiction: Alexandria 21)Style: Georgian Bedrooms: 3 Bathrooms: 2.5 Lot size: 0.5 Square acre Age: 6 Price: $359,000.00 Distance: 11.0 Jurisdiction: Arlington 22)Style: Townhouse Bedrooms: 3 Bathrooms: 2.5 Lot size: 0.0 Square acre Age: 26 Price: $259,000.00 Distance: 6.0 Jurisdiction: District of Columbia 23)Style: Rambler Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.2 Square acre Age: 17 Price: $357,000.00 Distance: 13.0 Jurisdiction: Arlington 24)Style: Townhouse Bedrooms: 3 Bathrooms: 35.0Lot size: 0.0 Square acre Age: 19 Price: $249,000.00 Distance: 1.0 Jurisdiction: Alexandria 25)Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.2 Square acre Age: 13 Price: $399,000.00 Distance: 12.0 Jurisdiction: Alexandria 26)Style: Rambler Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.22 Square acre Age: 13 Price: $349,000.00 Distance: 7.5 Jurisdiction: Arlington 27)Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.75 Square acre Age: 12 Price: $399,000.00 Distance: 9.8 Jurisdiction: Alexandria 28)Style: Colonial Bedrooms: 3 Bathrooms: 2.5 Lot size: 1.4 Square acre Age: 19 Price: $289,000.00 Distance: 11.0 Jurisdiction: Falls Church 29)Style: Georgian Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.2 Square acre Age: 2 Price: $350,000.00 Distance: 14.0 Jurisdiction: Fairfax 30)Style: Condominium Bedrooms: 3 Bathrooms: 3.0 Lot size: 0.0 Square acre Age: 15 Price: $305,000.00 Distance: 4.0 Jurisdiction: Arlington Would you like to create a new set of home listings? Enter yes or no. yes For this list of homes which real-estate agencies would you like the home listings drawn from? Please enter their numbers on one line 1) Century 21 2) ReMax 3) McEnearney 4) Long & Foster 2 3 4 Please choose a home criteria and enter its number. 1) Style 2) Number Of Bedrooms 3) Number Of Bathrooms 4) Lot Size 5) Age 6) Price 7) Distance From Work 8) Jurisdiction 6 Please choose the Price and enter its number. 1) under 100 thousand 2) 100 thousand to 150 thousand 3) 150 thousand to 200 thousand 4) 200 thousand to 300 thousand 5) 300 thousand to 400 thousand 6) over 400 thousand 4 The list of realstate agencies used are: ReMax McEnearney Long & Foster The price of the house ranges from $200,000.00 to $300,000.00. 1 )Style: Townhouse Bedrooms: 2 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 16 Price: $296,000.00 Distance: 7.0 Jurisdiction: Falls Church 2 )Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.2 Square acre Age: 14 Price: $249,000.00 Distance: 1.0 Jurisdiction: Fairfax 3 )Style: Condominium Bedrooms: 3 Bathrooms: 2.5 Lot size: 0.0 Square acre Age: 11 Price: $219,000.00 Distance: 16.0 Jurisdiction: Falls Church 4 )Style: Condominium Bedrooms: 2 Bathrooms: 1.0 Lot size: 0.0 Square acre Age: 13 Price: $259,000.00 Distance: 13.0 Jurisdiction: Fairfax 5 )Style: Townhouse Bedrooms: 3 Bathrooms: 2.5 Lot size: 0.0 Square acre Age: 26 Price: $259,000.00 Distance: 6.0 Jurisdiction: District of Columbia 6 )Style: Townhouse Bedrooms: 3 Bathrooms: 35.0Lot size: 0.0 Square acre Age: 19 Price: $249,000.00 Distance: 1.0 Jurisdiction: Alexandria 7 )Style: Townhouse Bedrooms: 2 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 11 Price: $299,000.00 Distance: 6.0 Jurisdiction: Alexandria 8 )Style: Condominium Bedrooms: 2 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 17 Price: $289,000.00 Distance: 7.5 Jurisdiction: Falls Church 9 )Style: Colonial Bedrooms: 3 Bathrooms: 2.5 Lot size: 1.4 Square acre Age: 19 Price: $289,000.00 Distance: 11.0 Jurisdiction: Falls Church 10)Style: Condominium Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 1 Price: $249,000.00 Distance: 13.0 Jurisdiction: District of Columbia 11)Style: Rambler Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.25 Square acre Age: 17 Price: $249,000.00 Distance: 13.0 Jurisdiction: Falls Church 12)Style: Colonial Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.5 Square acre Age: 14 Price: $249,000.00 Distance: 7.0 Jurisdiction: Arlington 13)Style: Split Level Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.75 Square acre Age: 7 Price: $249,000.00 Distance: 5.8 Jurisdiction: Fairfax 14)Style: Georgian Bedrooms: 3 Bathrooms: 1.5 Lot size: 1.4 Square acre Age: 19 Price: $289,000.00 Distance: 1.0 Jurisdiction: Arlington 15)Style: Condominium Bedrooms: 2 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 4 Price: $245,000.00 Distance: 7.0 Jurisdiction: Falls Church 16)Style: Rambler Bedrooms: 3 Bathrooms: 2.0 Lot size: 1.4 Square acre Age: 18 Price: $289,000.00 Distance: 16.0 Jurisdiction: Alexandria 17)Style: Townhouse Bedrooms: 3 Bathrooms: 2.0 Lot size: 0.0 Square acre Age: 14 Price: $259,000.00 Distance: 5.0 Jurisdiction: Alexandria Would you like to create a new set of home listings? Enter yes or no. no Thank you for creating home listings.
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