Hi Jim - There's a couple things missing from the code; in the readIntValues() method, there's a reference to io that isn't supported anywhere else in the class. One can assume it's an InputStream or Reader, but since it isn't declared or instantiated anywhere, I can only assume "io" is supposed to be a stand-in for System.in. On the other hand, I don't know which class (if any) allows you to prompt the user as a argument to some input type, and expect an integer in return. It's been a while since I've done any client-side java and I don't have the JDK docs at hand, so I dunno know. But we need a little more to go on here. ------------------ Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Jim gross
Greenhorn
Joined: Sep 24, 2001
Posts: 4
posted
0
Hi Mr. Ernest, Thank you for answering my question. I forgot to send the rest of the code. Here they are. public class List {
private int element; private List next; public List() {
element = 0; next = null; } public List(int elem, List nextElem) { element = elem; next = nextElem; } public void setElem(int someElement) { element = someElement; } public void setNext(List newNext) { next = newNext; } public int getElem() { return element; } public List getNext() { return next; } } public class io { public io() { }
static String readString() { int ch; String r = ""; boolean done = false; while (!done) { try { ch = System.in.read(); if (ch < 0 | | (char)ch == '\n') done = true; else if ((char)ch != '\r') r = r + (char) ch; } catch(java.io.IOException e) { done = true; } } return r; }
static void error(String err) { throw new Error(err); }
}
Jamie Young
Ranch Hand
Joined: Jun 19, 2001
Posts: 31
posted
0
Have you considered using the LinkedList class java.util.LinkedList? I would test your program against it. After all it is a concrete collection. It is easy to use. ------------------
Jim gross
Greenhorn
Joined: Sep 24, 2001
Posts: 4
posted
0
But I still don't know how to write a test class. How do I start?
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
You can just add a main() method to your LinkedList class and work with it. Or you can create a separate class Test that has the main and use it to test your stuff.
[This message has been edited by Cindy Glass (edited September 25, 2001).]
"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.