I have to make yet another quiz and I am COMPLETELY lost.
I have to make use of classes, so one java file that uses the class file of another java code that tells the other what to do.
I have one class file containing:
/** Rectangle class, phase 3 Under construction! */ public class FillInBlank { private String question; private String answer; private String cans; // correct ans private String gans; // given ans /** Constructor */ public FillInBlank(String Q, String A) // Question and Answer { question = Q; cans = A; } public String getQuestion() { return question; } public String getcans() { return cans; } public String getgans() { return gans; } public void setans(String correctAns) { cans = correctAns; } public boolean check() { if (gans.equals(cans)) return true; else return false; } //needs setter for given ans }
Then I have another java file that has the actual quiz in it but I am SO lost of where to go from here
import java.util.Scanner; public class HW7 { public static void main(String[] args) { String input; Scanner keyboard = new Scanner(System.in); FillInBlank Q1 = new FillInBlank("What programming lang?","java"); FillInBlank Q2 = new FillInBlank("what command makes summary","javadoc"); System.out.println(Q1.getQuestion()); input = keyboard.nextLine(); }
How do I get a user's answer and how do I output if it's correct or not.
I am sorry if I am being very vague but to be honest not even I understand what my professor wants this week.