Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.io.File;
- import java.io.FileWriter;
- import java.util.ArrayList;
- import java.util.regex.*;
- public class QuestionsTest {
- public static void main (String[] args) {
- Scanner in = new Scanner(System.in);
- Questions basicQuiz = new Questions();
- Questions binaryQuiz = new Questions();
- /*
- System.out.println("Please enter the file you want to read: ");
- String filename = in.next();
- //String filename = in.nextLine();
- File fileIn = new File (filename);
- try {
- Scanner file = new Scanner(fileIn);
- while(file.hasNextLine()) {
- // Get a line of the text file
- String line = file.nextLine();
- // Separate the line into name and number
- String[] parts = line.split(",");
- String temp1Question = parts[0];
- String temp1Answer1 = parts[1];
- String temp1Answer2 = parts[2];
- String temp1Answer3 = parts[3];
- String temp1Answer4 = parts[4];
- String temp1corAnswer = parts[5];
- // Create an entry and add it to the Student Details
- basicQuiz.add(temp1Question, temp1Answer1, temp1Answer2 , temp1Answer3, temp1Answer4, temp1corAnswer);
- }
- file.close();
- }
- catch( Exception e ) {
- System.out.println( "Problem reading file: " + filename );
- }
- System.out.println(basicQuiz);
- in.nextLine();
- int tempHolderswag = 0;
- int loops = 0;
- int arraySize = basicQuiz.size();
- for(int i = 0; i < arraySize; i++) {
- String correctValue1 = basicQuiz.get(i).getcorAnswer();
- String questionlol = basicQuiz.get(i).getQuestion();
- String output1 = basicQuiz.get(i).getAnswer1();
- String output2 = basicQuiz.get(i).getAnswer2();
- String output3 = basicQuiz.get(i).getAnswer3();
- String output4 = basicQuiz.get(i).getAnswer4();
- System.out.println("Select a choice");
- System.out.println(questionlol);
- System.out.println("Options");
- System.out.println(output1);
- System.out.println(output2);
- System.out.println(output3);
- System.out.println(output4);
- String tempValue = in.nextLine();
- if (tempValue.matches(correctValue1)) {
- System.out.println("You are correct");
- tempHolderswag += 1;
- } else {
- System.out.println("You are retarded");
- }
- }
- //Score
- System.out.println(tempHolderswag + " / 10");
- //Add a Question to the array
- /*
- System.out.println("Please enter the Question: ");
- String tempQuestion = in.nextLine();
- System.out.println("");
- System.out.println("Please enter Answer 1: ");
- String tempAnswer1 = in.nextLine();
- System.out.println("");
- System.out.println("Please enter Answer 2: ");
- String tempAnswer2 = in.nextLine();
- System.out.println("");
- System.out.println("Please enter Answer 3: ");
- String tempAnswer3 = in.nextLine();
- System.out.println("");
- System.out.println("Please enter Answer4: ");
- String tempAnswer4 = in.nextLine();
- System.out.println("Please enter the Correct Answer: ");
- String tempcorAnswer = in.nextLine();
- basicQuiz.add(tempQuestion, tempAnswer1, tempAnswer2, tempAnswer3, tempAnswer4, tempcorAnswer);
- System.out.println(basicQuiz);
- //Delete a Qusetion by index
- /*
- System.out.println("Current Questions in General Knowledge:\n");
- for(int i = 0 ; i < basicQuiz.size(); i++ ) {
- String tempDelete = basicQuiz.get(i).getQuestion();
- System.out.println((i+1) + ": " + tempDelete);
- }
- System.out.println("Please enter the index of user you want to delete\n");
- int temptempSelection = in.nextInt();
- int tempSelection = temptempSelection - 1;
- basicQuiz.remove(tempSelection);
- System.out.println("\nThe Question of Index: " + temptempSelection + " has now been deleted");
- for(int i = 0 ; i < basicQuiz.size(); i++ ) {
- String tempDelete = basicQuiz.get(i).getQuestion();
- System.out.println((i+1) + ": " + tempDelete);
- }
- */
- //End points
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement