Java PLEASE DON\'T SPAM OR POST IRRELEVANT ANSWERS OR I WILL REPORT YOU Would ap
ID: 3824745 • Letter: J
Question
Java
PLEASE DON'T SPAM OR POST IRRELEVANT ANSWERS OR I WILL REPORT YOU
Would appriciate any help
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<Agency> agencyArray = new ArrayList<Agency>();
private ArrayList<RealEstateListing> listingsFromOneAgency = new ArrayList<RealEstateListing>();
private ArrayList<RealEstateListing> finalArrayListOfRealEstateListings = new ArrayList<RealEstateListing>();
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<RealEstateListing> style(int styleType, ArrayList<Agency> 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<RealEstateListing> realEstateListingArray = new ArrayList<RealEstateListing>();
public Agency(String agency, String agencyFile) {
// *** Constructor reads its file into an ArrayList
// *** don’t 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<RealEstateListing> 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;
}
}
remax.txt
rest the text files are in this format
Output sample:
Explanation / Answer
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<Agency> agencyArray = new ArrayList<Agency>();
private ArrayList<RealEstateListing> listingsFromOneAgency = new ArrayList<RealEstateListing>();
private ArrayList<RealEstateListing> finalArrayListOfRealEstateListings = new ArrayList<RealEstateListing>();
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<RealEstateListing> style(int styleType, ArrayList<Agency> 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<RealEstateListing> realEstateListingArray = new ArrayList<RealEstateListing>();
public Agency(String agency, String agencyFile) {
// *** Constructor reads its file into an ArrayList
// *** don’t 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<RealEstateListing> 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;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.