Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

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 agencyArray = new ArrayList(); private ArrayList listingsFromOneAgency = new ArrayList(); private ArrayList finalArrayListOfRealEstateListings = new ArrayList(); private String answerSoFar = ""; private Agency century21 = null; private Agency reMax = null; private Agency mcEnearney = null; private Agency longAndFoster = null;

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 style(int styleType, ArrayList agencyArray) { // *** ask each agency to give a list that satisfies the requested // style. }

// *** 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 realEstateListingArray = new 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 style(String desiredStyle) { // *** Creates an ArrayList of for this criteria. // *** Each criteria creates a list. } }

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; }

}

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

Step: 3

blur-text-image

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

How is social networking used in informal training?

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago