![]() |
need help with code plz
hey guys, ive been constantly strugglying to get my code working but have had no luck. i have 2 classes, ListDictionary.java & wordbase1.java which are both linked lists that have an inner node class. ListDictionary.java is an array of linked lists, which reads words in from a text file called dictionary.txt, where for the array every element of the array represents a letter of the alphabet, and contains a linked list of words in alphabetically order starting with that letter. The wordbase1.java is suppose to be a linked list containing all the words in the dictionary which is of 4 letters or less in length, in alphabetically order, and i seem to be getting errors with my array varible. My code is below, any help would be great!
:
public class wordbase1 extends ListDictionary:
import java.util.*;the errors im getting are... :
wordbase1.java:27: cannot find symbolI have been trying to fix it for a while but no luck yet, any help would be great. |
:
public ListDictionary() |
Quote:
Ok, so after looking over your code, I think the problem is with the first error you specified. Where is that array coming from? It's obviously having problems finding it. I'm not great at Java, so I can't say much. My advice to you is to start over with new clean empty files, recreating and copying over some code doing step by step, and see what you end up with. Anyways, good luck. |
You have a number of problems you need to fix.
The first, and most obvious, is the omission of a return statement in the wordbase1.wordbase.getWord method, which can be easily corrected: :
public String getWord():
protected ListDictionary[] array;In addition, you have a dilemma here: :
p.getWord() = array[i].getWord();:
setWord(array[i].getWord())Even after correcting the above errors, I believe it is safe to say you will have a long list of new problems to solve. If I were you, I would rewrite the code from scratch--it is certainly possible to do whatever you are attempting without two nested classes in two nested files, and worse, one of those nested classes extending the other nested class which is made possible by its outer class extending the class in which the class it is extending is nested. (Ugh!) No offense intended, but this may very well be the ugliest Java code I have ever seen. You might consider entering an obfuscated code contest. Good luck... |
:
case 'A': |
Or better yet:
:
if (Character.isLetter(line.charAt(0)))EDIT: Sane, you are correct. The code I provided only determines whether the letter is a character, not which index of the array to use. :
char c = line.charAt(0); |
| All times are GMT -5. The time now is 1:17 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC