package com.ssj.service.conch.parents.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author chchen
 */
public class KnowledgePointDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String style;
    private int wrongNum;
    private int totalNum;
    private int percent;
    private List<NoKnowledgePointDto> noKnowledgePoint;

    public KnowledgePointDto (){

    }

    public KnowledgePointDto (String style) {
        this.style = style;
        this.noKnowledgePoint =  new ArrayList<>();
    }

    public String getStyle() {
        return style;
    }

    public void setStyle(String style) {
        this.style = style;
    }

    public int getWrongNum() {
        return wrongNum;
    }

    public void setWrongNum(int wrongNum) {
        this.wrongNum = wrongNum;
    }

    public void addWrongNum (int wrongNum) {
        this.wrongNum += wrongNum;
    }

    public int getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(int totalNum) {
        this.totalNum = totalNum;
    }

    public void addTotalNum  (int count) {
        this.totalNum += count;
    }

    public int getPercent() {
        return percent;
    }

    public void setPercent(int percent) {
        this.percent = percent;
    }

    public void calculatePercent () {
        if (this.totalNum == 0){
            this.percent = 0;
        } else if (this.totalNum < this.wrongNum){
            this.wrongNum = this.totalNum;
            this.percent = 100;
        } else {
            this.percent = (int)((float)this.wrongNum / this.totalNum  * 100);
        }
    }

    public List<NoKnowledgePointDto> getNoKnowledgePoint() {
        return noKnowledgePoint;
    }

    public void setNoKnowledgePoint(List<NoKnowledgePointDto> noKnowledgePoint) {
        this.noKnowledgePoint = noKnowledgePoint;
    }

    public void addNoKnowPoint (NoKnowledgePointDto dto){
        this.noKnowledgePoint.add(dto);
    }
}