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

import java.util.ArrayList;
import java.util.List;

public class ScoreInfo {

    private int mainNumber;

    private int subNumber;

    private String mainTitle;

    private double objectiveScore;

    private double subjectiveScore;

    private double totalScore;

    private List<ScoreItem> scoreList;

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

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

    public void addScore(String title, int number, double score, String answer, boolean objective) {
        subNumber++;

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

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

    public double getObjectiveScore() {
        return objectiveScore;
    }

    public double getSubjectiveScore() {
        return subjectiveScore;
    }

    public void setSubjectiveScore(double subjectiveScore) {
		this.subjectiveScore = subjectiveScore;
	}

	public double getTotalScore() {
        return totalScore;
    }

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

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

    public int getMainCount() {
        return mainNumber;
    }

}
