

-----------------------------------

poo

Sun Jan 11, 2009 7:11 pm


help...with string tokenizing and assignin to arrays

-----------------------------------

hi everyone??

i m making a basic quiz game i need help help assigning tokens to differernt arrays.... so far i m readin in a file tokenizing it and then assignin it to one array
wht i wanna do is:
have different arrays for each such as:
Question[]
A[]
B[]
C[]
D[]
rightAns[]

this is ma file THE QUESTIONS CHOICES AND THE RIGHT ANSWER AT THE END IS DIVIDED BY @..

what is the flame that continually remain lite in many older-model gas stove?@stove candle@bunt flame@pilot light@rocket engine@bunt flame
A hidden resource saved for use at a critical time is called a wht "in the hole"?@map@ace@candle@lifeline@candle
A cadiology specializes in wht part of the human body?@eyes@heart@hair@ears@heart
What does a pH level measure?@humidity@density@acidity@Wavelength@acidity
Which of these holidays is not attached to a specific date?@Christmas@IndependenceDay@Thanksgiving@NewYear'sDay@christmas
What famous radio personality was also the voice of Shaggy on the cartoon 'Scooby-Doo'?@Rush Limbaugh@Casey Kasem@Larry King@Larry King
What type of substance is 'terra-cotta'?@glass@metal@ceramic@wood@wood

this is ma program so far.. and now i m confused??

// The "DEMO" class.
import java.awt.*;
import hsa.Console;
import java.io.*;
import java.util.*;

public class split
{
    static Console c;           // The output console

    public static void main (String[] args) throws IOException
    {
        c = new Console ();

        String line;
        BufferedReader input;
        input = new BufferedReader (new FileReader ("original.txt"));
        line = input.readLine ();

        String[] q = line.split ("\\@");
       
        for (int x = 0 ; x < q.length ; x++)
            c.println (q [x]);

   THIS IS READING IN THE QUESTION AND ALL FOUR CHOICES AND THE RIGHT ANSWER INTO ONE ARRAY HOW DO WE MAKE IT SO THEY GO INTO DIFFERENT ARRAY'S


PLEASE HELP IF U CAN........... :cry:


-----------------------------------

DemonWasp

Mon Jan 12, 2009 9:36 am


RE:help...with string tokenizing and assignin to arrays

-----------------------------------

The array q has exactly 6 entries (question text, A, B, C, D, correct answer). So when you read the i-th line, you should assign Questionnew the array, so you can be sure it's the right size.

