|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
|
Java
Hi, I've got problems w/ this code and I'm not sure what's up. I thought this made logical sense, and my programming teacher (who doesn't speak english very well) told me it was logical, but all he's done is give me examples of multithreading. Which don't seem to be what I want for this case (w/ the thread.sleep function). This is my own personal project, so you don't have to worry about this actually being for the class. Thanx in advance for any help you can give.
snow (I know the blocking is weird, but it looks more logical to me that way-- sorry.) P.S. I had to make it a regular text file cause the forum doesn't exept files w/ Java extensions |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Nov 2001
Posts: 1,965
|
You didn't mention the job of this code, so I can't know if this code is logical or not, please tell me what do you want from your code so I can help you more.
I can give some notes though: Line 6: your code: class static exec{ correct code: static class exec{ Reason: Modifiers (like public, static, final ...) should be before the class declaration, or the compiler won't accept the code. Line 21: Here, you use a run method with a boolean parameter called line1on, when the line1a object is executed, this mothed won't be invoked, instead, a run method (inherited from the Thread class) with no parameters and with an empty body will be executed, if you want your run method to be executed when the line1a object is started, remove the parameter and add matrix7. before each line1on in the run method body. BTW, even if the current run method is executed, the parameter line1on won't have the same value as the static field in class matrix7. Line 37: You missed a { after the while statement. Line 39: Your code: exec.a(); Correct code: e.a(); I think you already know why, method a is a non-static method, so you need an instance of exec to invoke it. Other notes:
Again, please tell me what do you want from this code so I can help you more. |
|
|
|
|
|
#3 |
|
Member (7 bit)
|
thanx
thanx, a lot of that looks really stupid of me in hindsight, but I'm new to this and I don't catch everything. I"m slowly working through this Java book, and I was doing this matrix project as a side thing as I learned the material to execute it. Basically, I'm trying to recreate the opening scene ("Wake up, Neo... Cls "The matrix has you...) and I'm slowly but surely getting through some stuff. I picked up the sleep function (which is way beyond where I am in this book) from a post on the Sun Java forum-- so I"m not surprised if the syntax is off a bit. The boolean while loop stuff was another option I was trying instead of multithreading (I'm one of those people that once they think of an alternate way of doing something, they have to try it-- plus I don't totally get the multithreading and my teacher doesn't speak english very well). I wanted to run the first thread, clear the screen, run the second thread, etc. And that would work if I could get windows to clear the screen during a Java execution(it works fine under Linux). I know I'm rambling, but I hope that gives you a better idea. THANX A LOT! I don't think I would have figured this out on my own for a very long time.
nate P.S. I'll fix those errors right after easter dinner
|
|
|
|
|
|
#4 |
|
Registered User
Join Date: Nov 2001
Posts: 1,965
|
OK, keep up the good work
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|