Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Tobias Hess

Ranch Hand
+ Follow
since Apr 06, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tobias Hess

Delete this lines, and see if it works:

REM adding a path to Java compiler

set JAVA_HOME=F:\Program Files\IBM\Websphere Studio\runtimes\base_v5\java\bin
set path=%JAVA_HOME%;%path%


Wich java are you using? Looks like you have two installed, one with websphere and one with the j2sdk.

The problem is, that your profiler can't find the class javax/xml/parsers/DocumentBuilderFactory - this is a java-standard class, it comes with the j2se and it shouldn't be a problem to find it for the java interpreter from sun! I don't know nothing about websphere, so i can't help you to make it work with that.
17 years ago
Unicast means there is one receiver, use it if there's maximal one receiver. Use multicast to allwo one-to-many connections, an example for multicast is the java eventhandling modell.
17 years ago

Add classpaths to point to those jar files.



Here's the problem, check your classpath.
17 years ago
Howdy,
there are thousands of books about java out there, choose one and look it up. My favorite is Thinking in Java, wich comes for free.
If you have concrete questions, feel free to ask them.
cu,
Tobias
18 years ago
How do I handle "The Matrix" ?
You can't, the matrix handles you.
For simple matrix things you can use arrays. Look it up in your favorite textbook. More complex things can be done by creating a class, as Ellen mentioned before.
Tobias
18 years ago
Allright, that's pretty much the same thing what I had. It should work just fine. ;-)
I don't know your book, and what topics have you learned until now. To do it the way I suggest it in previous posts, you need to know about classes and objects, object instantiation, methods, parameters, return types. From the level of your confusion about constructors and the like (sorry) I assume that you're not yet ready for this. Maybe a solution with all the code in main and without objects and methods is the right one. (That's what you had allready, isn't it?) What did you learn so far? If the focus was on expressions, statements and control flow the main-solution should be ok.
Later you can always come back to this exercise and solve it in another way.
HTH,
Tobias
18 years ago
Open the file Appointment.java, add a new first line to that file like this:
class Patient { }
What error messages are you getting now?
The only problem with your code is that the compiler can't find the Patient class for some reason.
Another thing to try out is to comment out every package statement in both files (you said they are both in the same directory).
Tobias
18 years ago
Hi Stacey,
it doesn't look that bad to me now. You could improve the first constructor with the suggestions Fred gove you about checking the parameter to be none-zero.
I know the first part of my code alone works to display:
How can you know? The code doesn't compile yet, does it?
Maybe it would be helpfull if we have some insights in your learning situation. Why do you learn java? How do you do it? Do you have a good textbook in place?
Tobias
18 years ago
cannot resolve symbol: class FirstClass in class Association
Could it be that the compiler somehow think FirstClass is a inner class in Association? Please, post the complete error messages including the correspondending lines of your code where that error occurs.
Just to be sure that it's not an issue with packages and files, try to copy the two classes in the same file as the association class. Another thing to try before jumping out of the window is 'make clean' or it's equivalent in your ide.
Tobias
18 years ago
I'm sorry to be dense - please define log and also console (session).
You're not, those words are badly chosen. Console means dosbox in Windows terms. With log I mean all the text that apperas in your dosbox from start to end of whatever you do.
I could still SWEAR that when I took the java class last year, the Nutty Professor had us saving files at the root level in a "java" folder and in the DOS window, we would simply change directory to C.
I believe that. It could be set up that way. It just doesn't make sense to do it, so don't bother. Make a directory of your choice, cd to it, edit your source file and compile it from there.
Good luck with learning java (again),
Tobias
18 years ago
Check my original message.
Ok, here we go.
Wrote a "Hello World" program in Notepad - saved as "hello.java" - there is no .txt extension (good!). The file is also in the "bin" subdirectory.
Thus, the file hello.java is in the jdk\bin directory.
I opened the command prompt screen and changed the directory to root C. At the C prompt, I type "javac hello.java" and the error message is this:
"error: cannot read: hello java
1 error"

Your actual directory is root C. It's exactly the error I described above.
Please, post a complete log of your console session. I'm sure we can figure it out.
Tobias
18 years ago
Ok, I went in to control panel --> system --> advanced --> enviromental variables and added the java directory (j2sdk1.4.2_04) to the existing path command. I also added the CLASSPATH command. I get the previous error message....
Make sure your in the same directory as the .java file. Make dir to verify it. Then, the error could not be the same as you've described above.
The enviroment variables are _not_ to tell the compiler where your source files (hello.java) are. Those can be anywhere you want them, for instance in c:>\work _but_ you have to be in the same directory, or give a full path name.
Let's say your actual directory is c:\ , and those hello.java is in c:\work. You can compile it from where you are, with javac c:\work\hello.java
If it still doesn't work, give us all the commands you enter including all error messages you get - copy it out of the console window and paste it in here.
HTH,
Tobias
18 years ago
Are all three classes in the same file? If not, in the same directory/package?
What you've written should work just fine. There's a problem with finding the other classes.
18 years ago

Well, I like your approach to learning. So let's look at your Rtnl class. That's really the center of your programm. You have to build a representation of Rational numbers inside your programm. What should it do? Let's start with what you've got so far.
The first thing that hurts me is the name. You should avoid cryptic abbreviations, let me suggest Rational as a more meaningful name.
The second thing that comes to mind is that the fields (numerator and denominator) are missing a private before the type. Always make fields private, that enabels encapsulation and this is key in oop. It would look like this:
private int numerator;
With that said, let's look at what the class does. Well, actually it realy doesn't do anything. You want to make a new Rational object like this
Rational r = new Rational(1,2);
and have it to store the Values 1 and 2 in the fields. Your constructor is missing that functionality, so you should add assignments from the parameters to the fields.
Allright, what should it do next? You want to be abel to add something to a Rational. You'll need a add() method. What parameter should it take? How to implement it? Well, first look at your main how you want to use it, then make it work.
Here is a snippet from your code:
Rtnl y1 = new Rtnl (1,Math.pow(2,y));
sum = sum.add(y1);
if (y1 !=10)
There are several problems in there. In fact, every line contains an error. Let's step through it.
The first line is tricky. Your constructor takes two parameters, both of type int. 1 is clearly an int, but what about the expression Math.pow(2,y)? the Math.pow() method returns a double, you can look that up in the api documentation. To make an int from a double, you have to put (int) before it. The compiler won't do it automaticaly for you. (Why? Think about it.) That would look like this:
r = new Rational(1, (int)Math.pow(2,n));
The second line trys to add something to a Rational. Beside of the still-to-come add() method, there's an error in your thinking here. You cannot assign something to a non-primitive variable. Well, you _can_ do it - but it doesn't work as you want it to. Look up reference types in your favorite java textbook. Eventually the code should look like this:
sum.add(y1);
The last line has the same problem as mentioned before. The != isn't working as expected, because again rtnl is not a primitive datatype. If you want that functionality, you have to write a method for it, for instance equals().
Allright, beside of add() and equals(), what else is missing? You want to be able to print rationals out. It would be handy to have a print() method, or even better a toString() method. Do you need to know (or modify, after construction) nominator and denominator? Write getters and setters for the fields. (Don't know what that is? Your javabook should tell you.)
Seems there's a lot of work waiting for you. Good luck.
HTH,
Tobias
[ April 21, 2004: Message edited by: Tobias Hess ]
18 years ago
Sorry, I don't understand the logic in your move()-method.
However, before attacking that logic, you should replace it with something that _allways_ changes the Position of your circels, let's say let them move to the right by 10 pixels. Now, have a look. If they move, check the logic. If they still not move, and that's what I guess, you have a problem with repainting the circels after changing they're position.
18 years ago