package cn.stylefeng.team.project.api.util;

public class Version {

    private int major;

    private int minor;

    public Version() {
        this.major = 1;
        this.minor = 0;
    }

    public Version(String versionStr) {

        String[] parts = versionStr.split("\\.");
        this.major = Integer.parseInt(parts[0].substring(1));
        this.minor = Integer.parseInt(parts[1]);
    }

    public int getMajor() {
        return major;
    }

    public int getMinor() {
        return minor;
    }

    public void setMajor(int major) {
        this.major = major;
    }

    public void setMinor(int minor) {
        this.minor = minor;
    }

    public void upgrade() {
        if (minor < 9) {

            minor++;
        } else {

            minor = 0;
            major++;
        }
    }

    @Override
    public String toString() {
        return "v" + major + "." + minor;
    }
}