Question: Java (put your CODE) Can you fix this, it shows error in getQuestion(), getScore(), rootcgetChildten().addAll, the setFont for questionLabel and scoreLabel, checkAnswer(userAnswer), answeField.clear() and setOnAction





public class QuizQuestion \{ private string question; private boolean answer; public QuizQuestion(String question, boolean answer) \{ this. question = question; this, answer = answer; public boolean checkAnswer (boolean userAnswer) return userAn er == answer: public String getQuestion ght return question: puo12c class QuizView extends Application \{ private QuizModel model; private Label questionLabel; private Label scoreLabel; private TextField answerField; goverride public void start(Stage primarystage) throws Exception model = new QuizModel (); questionLabel=newLabel(model.getCurrentQuestion()TgetQuestion());questionLabel.setFont(newFont("Aria1",20)); scoreLabe 1 = new Label ( "Score: " + mode1. getscore()); scorelabel. setfont (new Font("Ar Button submitButton = new Button ("Submit" ); submitButton. setonAction(event i boolean userAnswer = Boolean. parse8oolean (answerField, getText ()); boolean iscorrect = mode1, checkAnswer (useranswer); if (iscorrect) f 1. ScoreLabel.setText ("Score: " + model getscored)); answerfleld. clear (; Pise (iect alert - neiv alert(Alert.Aleretype. INFORMATIOW) alert.sptcontent fext (You hove complesed the quiz with a score of " + model gets. alert. shomanewait primarystage close scoreLabel. settext - scone: - mode2. iretscorecolo Button nextButton = new Button("Next"); nextButton. setonAction(event ; \{ QuizQuestion nextQuestion = model.getNextQuestion(); if (nextQuestion ! nu11) \{ questionLabel. setText(nextQuestion.getQuestion()); \} else \{ Alert alert = new Alert (Alert.AlertType. INFORMATION); alert. setContentText ("You have comnlotad bhe alert. setContent Text ("You have completed the quiz with a score of + model.getscor alert. showAndwait(); primarystage.close(); scorelabel. setText ("Score: n+ model. getscore ()); 3) answerField. clear(); VBox root = new VBox () ; root. setAlignment (POS.CENTER); root. setspacing (20); root. getchildren(), addall (questionlabel, answerfield, submitButton, nextButton, scoreLabel); Scene scene = new 5cene(root,400,400); primaryStage.setscene(scene); primarystage.show(); publie static void aain(Stringtd args) f launch (args); public class QuizModel L private List questions; private int currentQuestionIndex; private int score; public QuizNodel() ( questions = new ArrayList \langle angle() ; questions. add(new QuizQuestion("Is JavaFX a GUI 1Ibrary?". true) ): questions. fod(new QuizQuestion ("Is Java a dynanica11y typed language?", questionLabel = new Label(model. getQuestion().getQuestion()); scoreLabel = new Label( tert: "Score: " + nodel. getScore()); answerField = new TextField(); Button submitButton = new Button( label: "Submit"); Button nextButton = new Button( label: "Next"); root. getChildren(). addAlz (questionLabel, answerField, scoreLabez, submitButton, nextButton); questionlabel. setFont (new Font ("Courien New", 20)); scoreLabel. setfont(new Font ("Arial", 16)); submitButton. setonAction(event f boolean userAnswer = Bootean. porseBooteon(answerFiezd.getText()); boolean iscorrect = model.checkAnswer (usenAnswer); if (iscorrect) f scoreLabel.setText("Score: "+ adel.getscora()); f answerfield.chear(); b); nextButton. setoniction(event 1 if (nextquestion I = null i) questiontabet. setText (nextquestion. getQuestion()): 1 olse f
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
