Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes assignment help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "assignment help" Watch "assignment help" New topic
Author

assignment help

Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
can someone help me???
[ November 07, 2003: Message edited by: Dallas Costain ]
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Dallas:
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.


Dave
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Is your instructor Diego Zapata (diego.zapata@usask.ca),Jim Greer (greer@cs.usask.ca) or Guus van de Velde (guus@cs.usask.ca)? Just wonderin. . .


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Good advice


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
Here is what i have so far:

-------------
heres what im trying to sort: listings
House:123 Elm Street:125000
House:24 Bear Crescent:140000
Agent:John Smith
Agent :Arthur Dent
Agent:Ford Prefect
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:Mary Lamb
Agent:Jane Muffet
Agent eter Piper
House:123 Moose Road:150000
Agent:Monica Gellar
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 ]
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
hey, guys its not cheating. im asking for help - thats how i learn.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


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!


[Jess in Action][AskingGoodQuestions]
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
ok, yes it does compile. if you have a look at this part here:
//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());
return pick;
}

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??
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Ok, so post the code you have so far for sorting by address.


Please ignore post, I have no idea what I am talking about.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

The way to sort an array of objects is to use the overloaded java.util.Arrays.sort() methods, and to write an object which implements "Comparator" to do the comparing. You'll want an AddressComparator which, given two House objects, returns -1, 0, or 1 depending on whether the first address comes before, is the same as, or comes after the other. You can also write a SellingPriceComparator which compared by selling and an AskingPriceComparator as well.
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
thanks for the help, but i am still confused could you give me an example of what you mean?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
thank you - but is there a way i could do it without makeing a new class. ex. just make another method??
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

To use Comparitor you need to implement the interface, so you would need to create another class to do that.
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
but id there a way without using Comparator. could i use string tokenizer - if so how??
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
You could use an anonymous inner class in Arrays.sort.

Otherwise, you can always write your own method that implements a sorting algorithm. I would rather just use a Comparator.
Angel
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
Is there anybody on that can help me
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Geez, Dallas, what more do you want? We've shown you how to sort your houses by any criteria you'd like using only half a dozen lines of code -- two different ways! Now you take this code, and you try to apply it to your problem, and you read your textbook to try to understand what's going on, and then you come back and ask some more questions. How could we help you any more?
[ November 08, 2003: Message edited by: Ernest Friedman-Hill ]
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
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.
Angel
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Not sure what your last post was. But people have given you all the code examples you need to solve your problem. You just need to impliment them.
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?
Dallas Costain
Greenhorn

Joined: Nov 06, 2003
Posts: 12
yes it does
thank you vey much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: assignment help
 
Similar Threads
Majji Exm1 :
return value
what is your dream?
Need Guidance
octal, hex