Forums Register Login

Submission of a non working solution

+Pie Number of slices to send: Send
I am working on OOP2 and have got it to the point where I can not figure out what is going on. It compiles and I have placed System.out.println statments in the code to see where a certain issues occurs and cannot figure it out. My question is, should I go ahead and submitt it, or would it best to toil over the issue some more? I would rather not submitt the project but the whole debugging process is getting me down. The problem is hard to explain with out the code, so putting the question on the board would be a little difficult. Anyway, should I go ahead and submit it, or what?

Tony
+Pie Number of slices to send: Send
my personal opinion...or let me rephrase if i were you i wouldnt do it..one simple reason...a developer's credibility is built over a long time but one erroneous submission ruins it in a jiffy...

toil it out..some problems get solved on themselves...just by working on them..

Regards,
Rahul
+Pie Number of slices to send: Send
Hey Tony,

If you can figure out a way to ask for help on the forum without actually posting your code, that might be a way to get unstuck.

I don't have any specific "do" or "don't" advice with regards to submitting a solution that doesn't do what it is supposed to do. I think if you really a stuck, go for it! Heck - I have submitted solutions that I thought worked fine until the nitpicker answered with "yes, but what about this other specific case?".

Katrina
+Pie Number of slices to send: Send
Perhaps we can narrow it down a little bit. Is the problem with the HashMap, with the Exception throwing stuff, or with passing stuff back and forth between methods?

How long have you struggled with it? I don't want to rob you of an education, but it sounds like you've already got about as much education as you're going to get by yourself on this one.

I don't usually do this, but why don't you send me what you've got and I'll try to give you a hint that will get you over the hurdle.
+Pie Number of slices to send: Send
I appreciate the offer of help, I have narrowed it down to a specific statement. I get the system.out stuff to print fine till it, but then after that it won't work. I am pretty sure the HashMap stuff I understand, the exception throwing is another beast in itself though I think I finally did figure it out.

Lets see if I can explain as best I can. I seem to get into my toInt() the first time and it passes the if statement for the exception, goes into my for loop and then drifts off into space. The program exits 'normally' but nothing happens once it gets into the for loop. It may have to do with getting the value out of the HashMap. When setting up the HashMap I set it up with a String as the key and Integer as the value(it wouldn't let me use int, probably because it is a primitive and not an object though I thought autoboxing would take care of that). Then I have a piece of code to add the value to and int output variable. I have tried intValue() to change the Integer to int along with other stuff, but to now availe. Is that enough information for an idea or suggestion?

I will go ahead and send ya the code in the email, any hint or prod in the right direction would be greatly appreciated.

BTW...One would think that the Java API would be a little easier to navigate IMHO. I hate having to scroll for days just to get to the I's.

Tony
+Pie Number of slices to send: Send
 

Originally posted by Tony VanHorn:
When setting up the HashMap I set it up with a String as the key and Integer as the value(it wouldn't let me use int, probably because it is a primitive and not an object though I thought autoboxing would take care of that).


Ummm. Red flag. All assignments must be compatible with Java 1.4
+Pie Number of slices to send: Send
This saved me:



If it compiles, that is a very good sign.
+Pie Number of slices to send: Send
So I did the whole compile with the 1.4 stuff, now I can't fill an Integer array with ints such as:

Integer[] myArray = {1, 2, 3};

The compiler says that they are incompatible types. I don't get it. And then when I try:

output += Integer.intValue(myHashMap[0]); it says inconvertable type.

/me bangs head on desk!

Tony
+Pie Number of slices to send: Send
So, I change it to a String array and then added the two String arrays to my HashMap. Worked. Then when I pull it out I parse it to an int. Works. Did the whole javac -target 1.4 -source 1.4 FileName.java and it compiles. Yay, worked. Then I try and run it. It continues to do the same thing that it was doing before. It will start and end, but nothing prints up, no exceptions are thrown, no runtime errors.

Tony
+Pie Number of slices to send: Send
 

Originally posted by Tony VanHorn:
So I did the whole compile with the 1.4 stuff, now I can't fill an Integer array with ints such as:

Integer[] myArray = {1, 2, 3};

The compiler says that they are incompatible types. I don't get it. And then when I try:

output += Integer.intValue(myHashMap[0]); it says inconvertable type.
Tony



Autoboxing was introduced with Java 5. Before that an int didn't convert automatically to an Integer and vice-versa.
+Pie Number of slices to send: Send
BTW...One would think that the Java API would be a little easier to navigate IMHO. I hate having to scroll for days just to get to the I's.

I agree with that! It really has grown so large that it is pretty unmanagable now. Someone should come up with a better lookup method.

If you know which class you want to look at, you can go to javadoc online.
+Pie Number of slices to send: Send
 

Originally posted by Tony VanHorn:
It will start and end, but nothing prints up, no exceptions are thrown, no runtime errors.


It seemed to work just fine for me -- unless it threw an Exception.
+Pie Number of slices to send: Send
 

Originally posted by Marilyn de Queiroz:

It seemed to work just fine for me -- unless it threw an Exception.



Wait, you mean that what I sent you worked fine for you on your machine? It compile and displayed properly? If that is the case then my stuff is fubar.

[EDIT]Okay, so I think I am making progress. I actually get a null on the screen now when I run the program. Not big success, but hey I am glad its just printing something. Marilyn, you said to populate the HashMap directly without an algorithm. Did you mean


[EDIT Again] So I verified that the HashMap was being populated correctly by printing out myHashMap.entrySet() but I continued to get a null being printed after that. Then I figured out what the problem was. In my main, I have a try/catch and using the ex.message I was getting a null. I change it to "I should be getting a Message here" and it shows up. So I am getting a exception, but with a null message. So how am I suppose to fix something when it doesn't tell me whats wrong? ex.printStackTrace();

[ April 07, 2007: Message edited by: Tony VanHorn ]
+Pie Number of slices to send: Send
Yeah!! Got it figured out. I forgot to call the .toLowerCase() on my string, so it wasn't finding any keys in the hashmap that matched. And that threw the parse off. Sorry to ramble on in the last few post, but getting it out in words was definately a big help in figuring out the problem. You all are great listeners. I try and talk to my dog, but he just gets up an leaves. I think I annoy him. Anyway, thanks for the help and patience.

Tony
[ April 07, 2007: Message edited by: Tony VanHorn ]
+Pie Number of slices to send: Send
Marilyn, you said to populate the HashMap directly without an algorithm.

Something like
myHashMap.put("Zero", "0");

... Then I figured out what the problem was. In my main, I have a try/catch and using the ex.message I was getting a null. I change it to "I should be getting a Message here" and it shows up. So I am getting a exception, but with a null message. So how am I suppose to fix something when it doesn't tell me whats wrong?

So you're getting a RuntimeException rather than the Exception you threw...
Rather than a NumberFormatException, you probably want something more like "I didn't find this key in the HashMap"-type of exception. What sort of data are you passing in?
Is this happening with values that should be good? i.e.
java NaturalLanguageMultiply one twenty-one
??
with values like
java NaturalLanguageMultiply one tuonty-too
??
I'm not sure how you could get a NumberFormatException on a "22" unless you mistyped it as "2a" in your hashmap.
[ April 07, 2007: Message edited by: Marilyn de Queiroz ]
+Pie Number of slices to send: Send
I put everything in the hash map in all lower case. When I first check to see if the value is a key in the hashmap I used the .toLowerCase() and it would find the value. But while in the If statement I didn't use the .toLowerCase() on the value, so what should of been "twenty" was actually "Twenty" which isn't in the hashmap.
We can walk to school together. And we can both read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1010 times.
Similar Threads
B&S Question on RMI
Slowly getting it
Best practice for organizer DBUnit xml files
Java/J2EE to EAI
posting tech Articles
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:10:26.