• Post Reply Bookmark Topic Watch Topic
  • New Topic

Recursion  RSS feed

 
Josh Galeigh
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lots of recursion in class now. I though I understood this well enough but I'm having a lot of trouble with my work.
Class + Constructor:


Problem 1: There is actually no description of this problem but only the autograder method. I don't really understand what it is I should do so I'll post the grader code

I think it is taking the words from each linkedlist and then putting them in order. So it checks that they are in order and then checks the number of characters.. Not sure if that is correct or not.

Problem 2:



There's more but I'll stop here in case figuring these out illiminates the others.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Josh Galeigh wrote:Problem 1: There is actually no description of this problem

Then you need to ask your teacher for a description. You can't solve a problem if you haven't been told what the problem is.

Josh Galeigh wrote:Problem 2:

You've posted some code. Do you have a question ?
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably should not call your class LinkedList as it might be confused with java.util.LinkedList.
 
Josh Galeigh
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[quote=Joanne Neal
Then you need to ask your teacher for a description. You can't solve a problem if you haven't been told what the problem is.


You've posted some code. Do you have a question ?

1. Unfortunately that is not how this class works. He expects us to see what we need from the auto-grader. That is why I find these problems extremely frustrating. If I just knew what he wanted to begin with... But I think I know here, now. I am to take the given string and place it in the correct position within linkedlist. He then uses another method to make a sentence out of it to check that it is in the order A B C D. I've already got that method finished. We went over a similar problem in class today so this is what I got:


I'm not sure about using Integer.valueOf(). But I don't know how else to differentiate the values of the two strings. I thought of casting as chars but it wont let me do that to a string.

2. I am getting an error message saying I have the wrong value for the findLast(). This is what I have now:

 
Josh Galeigh
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:You probably should not call your class LinkedList as it might be confused with java.util.LinkedList.


Yeah, the linkedlist label comes with the problem. I'm not sure why they picked this.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Josh Galeigh wrote:I'm not sure about using Integer.valueOf().

Unless all your string contain only digits then you shouldn't use this as it will throw an exception for any non-numeric string.
There are various ways of comparing strings, but it's impossible to tell from the autograder code which way you should do it.
For example, is the comparison case-sensitive ? Should a come before of after B ?

Josh Galeigh wrote: I am getting an error message

What's the exact error message and which line does it refer to ?
 
Josh Galeigh
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Well, the auto-grader is only using capital characters if that helps. There is actually a second (invisible) grader but I can only work with what I see.
2. I get the message: junit.framework.AssertionFailedError: expected:<one> but was:<one;to;one>

So I guess I'm close on it but somehow I have 3 values instead of one in that link?

 
Josh Galeigh
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it. had to use compareTo() for the strings. And I didn't fully understand the other one until just now so I just got it too.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!