⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quizbean.java

📁 struts框架的jsf组件的核心实用例子集合
💻 JAVA
字号:
package com.corejsf;import java.util.ArrayList;public class QuizBean {   private ArrayList problems = new ArrayList();        private int currentIndex;   private int score;      public QuizBean() {            problems.add(         new ProblemBean(new int[] { 3, 1, 4, 1, 5 }, 9)); // pi      problems.add(         new ProblemBean(new int[] { 1, 1, 2, 3, 5 }, 8)); // fibonacci      problems.add(         new ProblemBean(new int[] { 1, 4, 9, 16, 25 }, 36)); // squares      problems.add(         new ProblemBean(new int[] { 2, 3, 5, 7, 11 }, 13)); // primes      problems.add(         new ProblemBean(new int[] { 1, 2, 4, 8, 16 }, 32)); // powers of 2         }      // PROPERTY: problems   public void setProblems(ArrayList newValue) {       problems = newValue;      currentIndex = 0;      score = 0;   }          // PROPERTY: score   public int getScore() { return score; }   // PROPERTY: current   public ProblemBean getCurrent() {      return (ProblemBean) problems.get(currentIndex);   }   // PROPERTY: answer   public String getAnswer() { return ""; }   public void setAnswer(String newValue) {       try {         int answer = Integer.parseInt(newValue.trim());         if (getCurrent().getSolution() == answer) score++;                     currentIndex = (currentIndex + 1) % problems.size();            }      catch (NumberFormatException ex) {      }   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -