I'm just learning Java, and i've been plugging away with a exercise in a book, but im a bit stuck!
I need to make a program that asks a user a question, takes there answer, and then checks it to make sure its correct. Here's what i have so far.
This is the main Class
/* * QuestionMain.java * * Created on 09 February 2006, 17:18 */ /** * * @author 04127263 */ import java.io.*; public class QuestionMain { static private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) { String question; Questions q1 = new Questions(3); q1.setAnswer(0, "The method does not return a value."); q1.setAnswer(1, "The method is empty."); q1.setAnswer(2, "The method doesn't do anything."); // TODO code application logic here question = "What does 'void' mean when it precedes the name of a method?"; System.out.println(questions(1)); System.out.println(questions(2)); System.out.println(questions(3)); System.out.println("Please Choose 0, 1 or 2"); } }
This is a Class
/* * Questions.java * * Created on 09 February 2006, 15:22 */ /** * * Christopher Murray 04127263 */ public class Questions { private String questionText; private String [] answers; String answerText; private int correctAnswer; //Creates an Instance of the class Questions public Questions(int noAnswers) { answers=new String[noAnswers]; } //Gets the Question from the Main Class public void setQuestion(String qText) { questionText = qText; } //This sets the answer numbers for the answer public void setAnswer(int answerNo, String answerText) { answers[answerNo]=answerText; } //Gets the number for the correct answer public void setCorrectAnswer(int answerNo) { correctAnswer = answerNo; } //Tests to check for correct answer public boolean qAnswerCorrect(int answer) { if (answer == correctAnswer) return true; else return false; } }
The main problem i having currently is that the Main Class calls the error -
Can not find symbol -
symbol : method questions(int)
location: class QuestionMain
System.out.println(questions(1));
Any help would be fantastic.
Thanks