简体   繁体   中英

Reading a test bank file into 2D Array

I'm trying to write a Java program, that reads a test bank file to a 2D array. The test bank is formatted like this . Here's a sample:

Java is an object-oriented programming language. An object-oriented language:

(a)Uses structured programming.

(b)Views a program as consisting of objects which communicate through interactions.

(c)Functionally breaks down problems into smaller, more manageable problems.

(d)All of the above.

B 

In Java, the equal sign is used as the ___________ operator.

(a)increment

(b)decrement

(c)assignment

(d)negation

C

In Java, source code is compiled into object code called ______________.
*...)

The test bank has lots of questions.

I'm trying to put the questions in the first dimension of the array and the answers in the second dimension, there are 4 answers and the correct answer letter is after the choices.

The problem is I want to assign variables to the questions and the answer and the correct letter but I have no idea where to start! :(

I want first a method to read the file then assign a variable, is there such a thing?

edit : this is some information from the instructor picture about the test bank

Thank you all.

the problem is i want to assign variables to the questions and the answer and the correct letter

You should modify your design. You required a list of [question (String), 4 answer choices (String) and index of correct answer]. That cannot fit in 2d array so :

You can begin as follows:

class Question
{
    String text;
    List<String> answerChoice;
    int answerIndex;
}

Now, you can have a List<Question> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM