com.ora.jsp.beans.poll
Class PollBean

java.lang.Object
  |
  +--com.ora.jsp.beans.poll.PollBean

public class PollBean
extends java.lang.Object

This class maintains a list of answers in an online poll application. It's only intended as an example.

Version:
1.0
Author:
Hans Bergsten, Gefion software

Field Summary
private  int answer1
           
private  int answer2
           
private  int answer3
           
private  int total
           
 
Constructor Summary
PollBean()
           
 
Method Summary
 int getAnswer1()
          Returns the number of alternative 1 answers.
 int getAnswer1Percent()
          Returns the percentage of alternative 1 answers.
 int getAnswer2()
          Returns the number of alternative 2 answers.
 int getAnswer2Percent()
          Returns the percentage of alternative 2 answers.
 int getAnswer3()
          Returns the number of alternative 3 answers.
 int getAnswer3Percent()
          Returns the percentage of alternative 3 answers.
private  int getPercent(int total, int answer)
          Returns an int representing the rounded percentage of answers.
 int getTotal()
          Returns the total number of answers.
 void setAnswer(AnswerBean answer)
          Increments the counter matching the answer as well as the total number of answers.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

total

private int total

answer1

private int answer1

answer2

private int answer2

answer3

private int answer3
Constructor Detail

PollBean

public PollBean()
Method Detail

setAnswer

public void setAnswer(AnswerBean answer)
Increments the counter matching the answer as well as the total number of answers.

getTotal

public int getTotal()
Returns the total number of answers.

getAnswer1

public int getAnswer1()
Returns the number of alternative 1 answers.

getAnswer2

public int getAnswer2()
Returns the number of alternative 2 answers.

getAnswer3

public int getAnswer3()
Returns the number of alternative 3 answers.

getAnswer1Percent

public int getAnswer1Percent()
Returns the percentage of alternative 1 answers.

getAnswer2Percent

public int getAnswer2Percent()
Returns the percentage of alternative 2 answers.

getAnswer3Percent

public int getAnswer3Percent()
Returns the percentage of alternative 3 answers.

getPercent

private int getPercent(int total,
                       int answer)
Returns an int representing the rounded percentage of answers.