Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java problem, looking for detailed solutions

leo16
leo16 


java GUI and other problems, please provide detailed solutions. Let me know before you start Attachments Tags Clarifications

Answers

Solutions

mariobeka
mariobeka 



In the zip file are the solution for every question. Attachments
Solution.zip (7 K) Download
Preview
to the user if you don't know what to do with their input protected abstract int getQuizSize(); //the number of questions to ask per quiz protected abstract ArrayList<Question> getQuestions(); //all of the questions protected abstract String getQuestionPrefix(Question question); //Text to print before the question is printed to the screen protected

Preview
BaseQuiz { private ArrayList<Question> allQuestions; //our single instance variable public FreeQuiz() {//constructor super();//call to superclass constructor allQuestions = populateList();//initialise instance variable allQuestions } //What to print if the user has given us a string that we can't use as an answer protected String invalidInput(Question question) { return "Your answer cannot

Preview
private String answer; public FreeQuizQuestion(String question, String answer)

Preview
for more info on varargs public MultipleChoiceQuestion(String question, int correctAnswer, String... answers) { super(question); this.answer = correctAnswer; possibleAnswers = Arrays.asList(answers); }

Preview
(MultipleChoiceQuestion) question; return "QUESTION (" + m.getPossibleAnswers().size() + " possible answers):"; } @Override protected String getQuestionSuffix(Question question) { StringBuilder sb = new StringBuilder("\n"); MultipleChoiceQuestion m = (MultipleChoiceQuestion) question; final int[] count = {0}; m.getPossibleAnswers().forEach(a -> { sb.append(++count[0] +". " + a +"\n"); }); sb.append("Enter a number> "); return sb.toString(); }

Preview
private String question; public Question(String question)

Preview
parameters in static methods or static fields. The classes type parameters are only in scope for instance methods and instance fields. For static

Preview
X

Preview
= Color.orange; Color color2 = Color.blue; boolean flag = false; public static void main(String[] args) { RectanglesGUI gui = new RectanglesGUI(); gui.go(); } //this method sets up the JFrame, adds the button and drawpanel to the frame and adds the ActionListener to the button public void go() { frame =

Preview
Question { private final boolean answer; public TrueFalseQuestion(String

Preview
instance of the class is made;", true); TrueFalseQuestion q4 = new TrueFalseQuestion( "Static methods can operate on instance variables;", false); TrueFalseQuestion q5 = new TrueFalseQuestion( "Instance variables hold the same value for every instance of the class;", false); list.add(q1); list.add(q2); list.add(q3); list.add(q4); list.add(q5); return list; } @Override protected boolean isValidAnswer(Question

Screenshots
Purchase Answer