package cn.com.qmth.stmms.biz.utils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class ScoreInfo {

    private int mainNumber;

    private String subNumber;

    private String mainTitle;

    private BigDecimal objectiveScore;

    private BigDecimal subjectiveScore;

    private BigDecimal totalScore;

    private List<ScoreItem> scoreList;

    public ScoreInfo() {
        this.mainNumber = 0;
        this.subNumber = "";
        this.objectiveScore = BigDecimal.ZERO;
        this.subjectiveScore = BigDecimal.ZERO;
        this.totalScore = BigDecimal.ZERO;
        this.scoreList = new ArrayList<ScoreItem>();
    }

    public int incrMainNumber(String title) {
        mainTitle = title;
        mainNumber++;
        subNumber = "";
        return mainNumber;
    }

    public void addScore(String title, String number, double score, String answer, boolean objective) {

        ScoreItem item = new ScoreItem(objective);
        item.setMainNumber(mainNumber);
        item.setSubNumber(number);
        item.setTitle(title != null ? title : mainTitle + "-" + item.getSubNumber());
        item.setAnswer(answer);
        item.setScore(score);

        scoreList.add(item);
        totalScore = totalScore.add(BigDecimal.valueOf(item.getScore()));
        if (item.isObjective()) {
            objectiveScore = objectiveScore.add(BigDecimal.valueOf(item.getScore()));
        } else {
            subjectiveScore = subjectiveScore.add(BigDecimal.valueOf(item.getScore()));
        }
    }

    public double getObjectiveScore() {
        return objectiveScore.doubleValue();
    }

    public double getSubjectiveScore() {
        return subjectiveScore.doubleValue();
    }

    public double getTotalScore() {
        return totalScore.doubleValue();
    }

    public List<ScoreItem> getScoreList() {
        return scoreList;
    }

    public int getTotalCount() {
        return scoreList.size();
    }

    public int getMainCount() {
        return mainNumber;
    }

}
