Yep, your right that was a link and yes, I'm sure someone can do it. In fact I'd be willing to be that a lot of people can do it. I can also bet that your teacher expects YOU to do it.
With all that said...
We'd be more than happy to help you out but most people here want to see that you've put some effort into it yourself. Show us what you've got so far, do you ahve any code? Does it compile? Or are you stuck trying to get started? Just asking someone to do it for you is not going to get you a lot of responses unless you also put an amount you'd be willing to pay there also. The people at the ranch like to help, we do it for free, but we dont like to just give things away to someone who is not going to put any effort into it themselves.
heres what im trying to sort: listings
House:123 Elm Street:125000
House:24 Bear Crescent:140000
Agent :Arthur Dent
House:666 Beelzebob Road:166600
House:42 Adams Drive: 242000
House:555 11th Street: 180000
House: 898 Brown Cres:240000
House:23 Pink Road:129900
House:15 Charles Avenue:127000
House :251 Semaphore Boulevard:130000
Agent eter Piper
House:123 Moose Road:150000
House:225 Fox Avenue: 360000
House:789 Deer Lane:188000
: houses sold
John Smith:Arthur Dent:123 Elm Street:122000
Ford Prefect:John Smith:24 Bear Crescent:140000
Arthur Dent:Ford Prefect: 42 Adams Drive:215000
Monica Gellar eter Piper: 225 Fox Avenue: 356000
Mary Lamb:Jane Muffet: 789 Deer Lane:178000
Jane Muffet:Monica Gellar:251 Semaphore Boulevard:127000
Mary Lamb:Arthur Dent:23 Pink Road:125500
Jane Muffet:Ford Prefect:15 Charles Avenue:128900
[ November 08, 2003: Message edited by: Thomas Paul ]
Here is what i have so far:
OK, so, throw us a bone: does this compile? What does it do? What part are you having trouble with? What part do you want to work on next?
I don't think anyone here is kindly enough to sit down and read through all of that. Using the UBB "CODE" tags would help, by making the code formatted, but still -- it's way too much for anyone to read. Try to ask more focused questions, please!
//this method should
//1) ask the user which houses to display and in what order
//2) sort the houses according to the criteria entered
//3) display the houses according to the criteria entered
public int displayHousesMenu() throws Exception
System.out.println("How would you like to display the houses? ");
System.out.println("1. All houses ordered by asking price");
System.out.println("2. All houses ordered by address");
System.out.println("3. Sold houses ordered by selling price");
System.out.println("4. Sold houses ordered by address");
System.out.println("5. Unsold houses ordered by asking price");
System.out.println("6. Unsold houses ordered by address");
System.out.print("Please select one of the options: ");
int pick = Integer.parseInt(kb.readLine().trim());
i think i got the sorting by asking price down, but im haveing trouble sorting by address. the file which i am sorting is posted below called listings. any help??
[ November 08, 2003: Message edited by: Ernest Friedman-Hill ]
Originally posted by Angel Dobbs-Sciortino:
You could use an anonymous inner class in Arrays.sort.
yah, thats the thing - we haven't learnt about comparators yet, so i need help writing a method that will sort.
Otherwise, you can always write your own method that implements a sorting algorithm. I would rather just use a Comparator.
You can't do something as simple as compare Strings, because you are working with House objects. For the price you were able to compare ints, but to be able to compare objects (in this case House objects) you need a Comparator to help you. You can't just say is "House1 > House2" because what are you comparing? House is an object which contains a bunch of things. What things within the House object do you want to compare? That is what you define using the Comparator. Does that make sense?
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
The WEB SERVICES and JAX-RS Coursehttps://coderanch.com/t/690789/WEB-SERVICES-JAX-RS