Originally posted by C.R.Muthukumar Muthukumar:
Pl arrange to make this program executable as there is problem in reading theDisk file continuously.
Originally posted by Joe Ess:
Welcome to the JavaRanch, Muthkumar. We love to talk Java and help people solve problems, but we are all volunteers and most of us don't have time to dig through 773 lines of code to figure out what's going on with your code. Your best bet to getting help is to post as specific a question as possible ("there is problem" is not specific), give us all the information we need to help you, like what the symtpoms of the problem are(i.e. an exception, bad output, unexpected behavior and so on) and a reasonable piece of code that demonstrates the observed behavior. Many times I've solved my own problems just trying to explain them well enough for someone else to understand them. Let us know if we can help you!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James:
This is probably just me being bad, but I don't look at more than about 10 lines of code on the ranch. I just don't have time to digest more.
Can you isolate the bit that doesn't work to a short method? Maybe make a skeletal main() method that calls it to demonstrate the problem? There's a pretty fair chance that during the process of doing that the problem will jump out at you. If not, a small chunk is a lot easier for us to look at.
I'm not trying to give you a hard time - just looking for a way to help you out. Cheers!
Originally posted by Joe Ess:
80 lines of code is still a lot to dig through. Perhaps you should work on one problem at a time, like reading a series of Strings out of a file. When you get that working, add features one at a time getting each to work before continuing on. Noone here has time to debug your program. However, in the spirit of compromise, I will tell you one thing. This loop:
will execute once. Do you see why?
Originally posted by C.R.Muthukumar Muthukumar:
will execute once. Do you see why?<hr></blockquote>
Hello and all the Cheers .Indeed ur methodology seems to be true for the execution of the whole lot of codes once, and this is exactly the same thing that i indicated from the beginning.Now I will try ur adding features one by one
At a try level:
Pl tell me atleast to get the thread working which is also a problem.
Pl review the codes as under:
class TimerThread extends Thread
{
int hh=0,mm=44,ss=59;
public void run()
{
while(true)
{
String tTime =new String(new Integer(hh).toString()+":"+new Integer(mm).toString()+":"+new Integer(ss).toString());
hh1.setIcon(new ImageIcon(new Integer(hh/10).toString()+".gif+"));
hh2.setIcon(new ImageIcon( new Integer(hh%10).toString() + ".gif" ));
colon1.setIcon(new ImageIcon("colon.gif"));
mm1.setIcon(new ImageIcon(new Integer(mm/10).toString()+".gif"));
mm2.setIcon(new ImageIcon(new Integer(mm%10).toString() + ".gif"));
colon2.setIcon(new ImageIcon("colon.gif"));
ss1.setIcon(new ImageIcon(new Integer(ss/10).toString()+".gif"));
ss2.setIcon(new ImageIcon(new Integer(ss%10).toString() +".gif"));
time.setText("tTime");
Font f= new Font("Serif",Font.BOLD,18);
time.setFont(f);
ss--;
if (ss==0)
{
ss=59;
mm--;
}
if (mm==0)
{
mm=59;
hh--;
}
try
{
Thread.sleep(1000);
}
catch(InterruptedException ie)
{
}
}
}
}
Tons & Tons of Thanks in advance
Originally posted by C.R.Muthukumar Muthukumar:
Originally posted by C.R.Muthukumar Muthukumar:
[qb]
will execute once. Do you see why?<hr></blockquote>
Hello and all the Cheers .Indeed ur methodology seems to be true for the execution of the whole lot of codes once, and this is exactly the same thing that i indicated from the beginning.Now I will try ur adding features one by one
At a try level:
Pl tell me atleast to get the thread working which is also a problem.
Pl review the codes as under:
class TimerThread extends Thread
{
int hh=0,mm=44,ss=59;
public void run()
{
while(true)
{
String tTime =new String(new Integer(hh).toString()+":"+new Integer(mm).toString()+":"+new Integer(ss).toString());
hh1.setIcon(new ImageIcon(new Integer(hh/10).toString()+".gif+"));
hh2.setIcon(new ImageIcon( new Integer(hh%10).toString() + ".gif" ));
colon1.setIcon(new ImageIcon("colon.gif"));
mm1.setIcon(new ImageIcon(new Integer(mm/10).toString()+".gif"));
mm2.setIcon(new ImageIcon(new Integer(mm%10).toString() + ".gif"));
colon2.setIcon(new ImageIcon("colon.gif"));
ss1.setIcon(new ImageIcon(new Integer(ss/10).toString()+".gif"));
ss2.setIcon(new ImageIcon(new Integer(ss%10).toString() +".gif"));
time.setText("tTime");
Font f= new Font("Serif",Font.BOLD,18);
time.setFont(f);
ss--;
if (ss==0)
{
ss=59;
mm--;
}
if (mm==0)
{
mm=59;
hh--;
}
try
{
Thread.sleep(1000);
}
catch(InterruptedException ie)
{
}
}
}
}
Tons & Tons of Thanks in advance
[/QB]
I tried to use for loop in place of while, in the above codes but in vain
pl would u give more clues on the same as i don'see why it is executing once only even though iterator is kept incrementing, and thanks
I tried to use for loop in place of while, in the above codes but in vain
pl would u give more clues on the same as i don'see why it is executing once only even though iterator is kept incrementing, and thanks
Originally posted by Joe Ess:
If the code inside a loop has a problem, changing the kind of loop isn't going to help. Read your code line by line and ask yourself what each line does. As a matter of fact, put comments after each line and repost the above code snippet.
And why, after I said you should work on one problem at a time, do you introduce another problem, the one with TimerThread?
Originally posted by Mike Southgate:
Not trying to interfere in the educational process here but...
M:
the loop will execute once only because the last line is return;. The return key word causes the method to end immediately.
ms
Originally posted by C.R.Muthukumar Muthukumar:
Hello
Any new year solution for this
Thanks for now However,the problem here is to make the loop repeat the way it read the first element(inside the bin file )thus ensuring for the comlete Text matter. This is not happening here , make ur self now free for the solution .Does the mix up of int and strings (that are stored in the file require delimitter,or is it that Handlers that has to publish the text matter is not effective if so pl suggest alternate)And finally what if one
tries to handle RandomAccessfile class with an extra method to accomodate an integer to idicate buffersize calling an extended class of RAF class
(String filename,String mode,int bufsize).Please make an early solution if this is not allowed.Thanks ,Best wishes for 2005
Originally posted by Joe Ess:
Happy new year to you as well. As I told you on December 16, your best bet is to work on one feature at a time. We're still volunteers here and can't debug this problem with everything else that's going on in your program. Strip out the code that reads the file and make a class that reads the file and prints to the console. If you still have a problem, tell us what the input file is like, what the desired result is, what the acutal result is and post the problem code. It would be nice if the code is less than 20 lines but still a running program. Since all you are doing is reading in a file, that should be no problem.
Originally posted by Joe Ess:
I'm sorry if the following sounds harsh, but if you are not even going to try to solve your problem, there is nothing we can do for you. On December 28, Mike Southgate posted the exact reason you get the first answer but no others. You have posted 3 times since then, asking the same question that he already answered. I suggested several times that you the code you posted for now and write on a small program which would just read the input file since it would be easier to debug. You have ignored this advice as well. We'd love to help you, but you still have to do the work.
It might simply be a language misunderstanding, but this is how I read the above.Originally posted by C.R.Muthukumar Muthukumar:
As ready reckoner the codes are there fully.it needs a little correction which I am sure javaranch can render without further delay.
Am I misinterpreting your post?[ My personal translation ]
I've posted all of the code needed to solve my problem. It only needs a few small corrections. Fix it for me now without delaying and wasting my time any further.
Originally posted by David Harkness:
Am I misinterpreting your post?
The purpose of Java Ranch is to provide a forum for people to help each other. Those of us that spend our personal time answering questions and helping people are not paid to do this. We do it for many reasons, but the goal is for us to help you help yourself and learn at the same time. We'd like to teach you to fish so you can feed yourself.
I post because people in the past have helped me (sort of repaying my karma balance), because I like to be a part of the community, because I really enjoy writing and learning about software, and because it feels good to help someone learn.
My boss gets to tell me what to do and demand I do it without delay. I certainly don't come here to get the same treatment. Again, if I am mistaken, I apologize, but the entire thread seems to support my view.
With much respect, please treat us with respect.
Originally posted by C.R.Muthukumar Muthukumar:
Hello
If u glimpse the whole lot of codes, u will know that RandomAccessFile class being used to trigger the text matter in the bin file.Please if somebody suggests as to how to retrieve datas that are persistively available, otherwise can any body render assistance to know if an iterator class be sandwitched along using whose method will i be able to read the
stuff ,if so which in place to put this and what are its methods,thus we as java persons can treat the operation of RAF class under collection pattern .pl note that my text matter in the bin file are objects grouped as arrays. Hope this would enhance u as well as me with a compromising solution.After all we r following a particular pattern used by another java person.Pl treat with++++++!!!Thanks(Pl note that text matter in bin file are not arraylist but only arrays(a)Questions,(b)4 ansewrs,(c)corectanswers etc
Originally posted by C.R.Muthukumar Muthukumar:
Hello
Since last 28th ,nobody responded, the codes as under were tried and got partial success since i am able to read the answers (in 4 RadioButtons) for any of the questions(out of 4 for example) .But still totally not operative continuos using Next or Previous buttons that are set in the program.The one time execution only occuring as pointed earlier, who would make the codes execute continuosly
....
public void populateQuestionsArray() throws FileNotFoundException,IOException
{
//FileInputStream fis=new FileInputStream("Harsha.bin");
RandomAccessFile rafQuestions= new RandomAccessFile("Harsha.bin","r");
try
{
// System.out.println("FileSize is :" +rafQuestions.length()+"bytes");
rafQuestions.seek(0);
long count1=Long.parseLong("0");//(starting posion)
long count2= Long.parseLong("1");//(no of bytes needed)
if(count1+count2 >rafQuestions.length())
count2=rafQuestions.length()-count1;
rafQuestions.seek(count1);
// while (rafQuestions.getFilePointer() < count2)
for(i=0;i<count2;i++)
{
try
{
//rafQuestions.readInt();
questionNos[i]=rafQuestions.readInt();
squestion=rafQuestions.readUTF();
subjectcode=rafQuestions.readUTF();
sans1=rafQuestions.readUTF();
sans2=rafQuestions.readUTF();
sans3=rafQuestions.readUTF();
sans4=rafQuestions.readUTF();
sca=rafQuestions.readUTF();
}
catch(EOFException e)
{
}
}
i++;
....
Pl note that that the Harsha.bin file used in RandomAccesFile class is a Disc file containing Text as said ealier..The solution is sought for continuos reading ,can any body render assistance
Originally posted by David Harkness:
I am trying one last time to assist you, Muthukumar. Quoting your entire previous post and saying "Please help me" doesn't add anything that can help us to help you.
Have you changed your code since your last post? If so, post it. Describe exactly what happens with more details rather than asking the same question. Also, reread this thread, for several people expressed their reasons for why they stopped trying to help you (mainly, you ignored their answer and asked the same question again).
If this is simply a language barrier, get a friend or coworker to translate for you. I think we've all been pretty clear so far.
In any case, good luck!
Originally posted by C.R.Muthukumar Muthukumar:
[QB]
Hello JavaProfessionals
A hardwork for a nearly month has brought me to enable the codes for execution as it now (only )reads the text matter from disk file
sequuencially but not able to tell me the total correct answers out of the 4 questions that were put in the file . As u will now be able to indicate as to how to get the correct Random Numbers made inorder to see that it doesnot say ArraysIndexoutofBounds though this was put under try/catch block
The portion of the codes questionNos =new int[4];
questionNos =new int[4];
Random rnd= new Random();
int a, b;
OuterLoop:
do
{
;
a=(int)(Math.random()*10 +1);
System.out.print("a = " +a);
b=(int) (Math.random() * 10 +1);
System.out.println("Trying b= " +b);
for(int j=1;j<=questionNos.length;j++)
{
System.out.println(j+ " "+b);
if(a == questionNos[j-1])
{
continue OuterLoop;
}else
if(a < totalq)
{
questionNos[i]=a;
correctFinalAnswers[i]=correctAnswers[a];
i++;
}
}
}
while(i<=3);
totalq =4;
i=0;
.....
Hello Java Specialist this is yet another portion of code for the same that was tried by me herein too, the result does not account for the correct answers that were clicked thru buttons it gives output as 4 out of 4 for whatever way we answer the questions (RadioButtons)Kindly throw some technical light and help Thanks
Originally posted by C.R.Muthukumar Muthukumar:
Originally posted by C.R.Muthukumar Muthukumar:
[QB]
Hello JavaProfessionals
A hardwork for a nearly month has brought me to enable the codes for execution as it now (only )reads the text matter from disk file
sequuencially but not able to tell me the total correct answers out of the 4 questions that were put in the file . As u will now be able to indicate as to how to get the correct Random Numbers made inorder to see that it doesnot say ArraysIndexoutofBounds though this was put under try/catch block
The portion of the codes questionNos =new int[4];
questionNos =new int[4];
Random rnd= new Random();
int a, b;
OuterLoop:
do
{
;
a=(int)(Math.random()*10 +1);
System.out.print("a = " +a);
b=(int) (Math.random() * 10 +1);
System.out.println("Trying b= " +b);
for(int j=1;j<=questionNos.length;j++)
{
System.out.println(j+ " "+b);
if(a == questionNos[j-1])
{
continue OuterLoop;
}else
if(a < totalq)
{
questionNos[i]=a;
correctFinalAnswers[i]=correctAnswers[a];
i++;
}
}
}
while(i<=3);
totalq =4;
i=0;
.....
Hello Java Specialist this is yet another portion of code for the same that was tried by me herein too, the result does not account for the correct answers that were clicked thru buttons it gives output as 4 out of 4 for whatever way we answer the questions (RadioButtons)Kindly throw some technical light and help Thanks
Hello java programmers
Pl let me get an idea as to how to find the total having given an array
(userChoices[] in the program) that contains 4 answers+ one correctAnswer prevailing in the disc, correctAnswers have to be added while answering via RadioButton,and the totalCorrect to be given as output.Will any one help me in completing this java coding successfully I am eager enough to get it
Thousands of thanks in advance
Originally posted by C.R.Muthukumar Muthukumar:
Hello java programmers
Pl let me get an idea as to how to find the total having given an array
(userChoices[] in the program) that contains 4 answers+ one correctAnswer prevailing in the disc, correctAnswers have to be added while answering via RadioButton,and the totalCorrect to be given as output.Will any one help me in completing this java coding successfully I am eager enough to get it
Thousands of thanks in advance
Don't get me started about those stupid light bulbs. |