Search:

Type: Posts; User: waltershc

Page 1 of 2 1 2

Search: Search took 0.10 seconds.

  1. Replies
    5
    Views
    1,046

    Re: need help constructing get method

    yes, to see if it exists. if it doesn't, return null.
  2. Replies
    5
    Views
    1,046

    Re: need help constructing get method

    I need the get method to receive a string value, check if it exists in the tree, and return either the object/key that the string corresponds to or a null value if it does not exist. I know I need...
  3. Replies
    5
    Views
    1,046

    need help constructing get method

    This is one of three trees I am using to parse text and print out every unique word, the line numbers it appears on, and the number of times it appears. I have already used a hash and tree map and...
  4. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    There is currently no point in my code that saves an item for checking. How would I save the value itr.next() prints? I cannot make some integer variable and just assign it to equal itr.next() as...
  5. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    I have tried various forms of that


    //local occurance variable
    int occurance = 1;
    String check = "";
    //System.out.println("pE entry=" + entry.getValue().toString());

    //print the...
  6. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    Unfortunately not. It is still printing out the second 3 for mouse.
  7. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    Output:
    wordMap=[cat=[2], mouse=[3, 3], phone=[4, 5], string=[1]]
    pE entry=[2]
    ID: [cat] Lines: 2 Occurance: [1]
    pE entry=[3, 3]
    ID: [mouse] Lines: 3, 3 Occurance: [2]
    pE entry=[4, 5]...
  8. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    So you are saying what needs to be inserted into the linked list needs to be a string including the line number instead of an integer? ...Or are we just talking about output for debugging purposes?
  9. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    What is your suggestion? I must be missing the point. I do not see how my printout is different from yours except for the concatenation of "wordMap=" and "pE entry=".
  10. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    wordmap is line 2. the values for each entry are above their respective entries.
    Running.
    [cat=[2], mouse=[3, 3], phone=[4, 5], string=[1]]
    [2]
    ID: cat Lines: 2 Occurance: 1
    [3, 3]
    ID:...
  11. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    I want to compare the objects(ints aka line numbers) in the linked list that are stored in the value location on the TreeMap.
  12. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    The linkedlist's line values.
  13. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    public static void printEntry(Map.Entry entry){

    //local occurance variable
    int occurance = 1;
    System.out.println(entry.getValue().toString());

    //print the word and the line numbers...
  14. Re: Could anyone please advise me on this unfinished code? THANK YOU! (I know there are errors)

    Well one problem I can see is that you are scanning for the name and score after the if-statements that test them. The if-statements would have already ran when the variables are filled with the...
  15. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    //Name: Hal Walters
    //Class: SCSC 321
    //Date: 3/10/2013

    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.util.*;

    public class driver1 {
  16. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    //Name: Hal Walters
    //Class: SCSC 321
    //Date: 3/10/2013

    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.util.*;

    public class driver1 {
  17. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    Forgive my ignorance, but where? There is a hasNext() call on line 49 when it runs through the iterator to call the printEntry method.
  18. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    So get rid of the elseif statement and put something in around the while loop at the bottom of the main class?
  19. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    Running.
    Exception in thread "main" java.util.NoSuchElementException
    at java.util.LinkedList$ListItr.next(Unknown Source)
    at driver1.printEntry(driver1.java:67)
    at...
  20. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    http://i110.photobucket.com/albums/n92/dcmystery21/Untitled-1.png

    Thanks for the help so far. Let me know if you cannot read the text.
  21. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    //Read the words and add them to the wordMap
    for (int lineNum = 1; (oneLine = inFile.readLine()) != null; lineNum++){
    StringTokenizer st = new StringTokenizer(oneLine);
    while...
  22. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    Not for a single identifier. In other words, any given line number should not appear more than once on a line in the console.

    --- Update ---



    I played around with that a little bit but...
  23. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    if (itr.toString() != itr.next().toString()){
    System.out.print(", " + itr.next());
    occurance++;
    }
    else{
    return;
    }


    well, i know this much already doesn't work. It should...
  24. Replies
    42
    Views
    2,665

    Re: Presumably simple fix sets/maps

    I updated the first post.

    Edit- Also went back and messed around with my code more and got it to a point where I feel it is even closer. I also added some code for formatting and counting word...
  25. Replies
    42
    Views
    2,665

    Presumably simple fix sets/maps

    I have made a good bit of progress with my code and am now stuck on something I believe to be quite simple. I have it printing out the line numbers that the word occurs on in the supplied text file...
Results 1 to 25 of 42
Page 1 of 2 1 2