package com.sysu.admin.controller.aland;

import lombok.Data;

import java.util.Arrays;

@Data
public class CropAreaStat {
    public CropAreaStat(){}

    public CropAreaStat(String cropType, String name, String color) {
        this.cropType = cropType;
        this.name = name;
        this.color = color;
    }

    private String cropType;
    private String name;
    private Double area = 0.0;
    private String color;
    private Integer count = 0;

    public static  String[] cropTypes = {"corn","rice","other","guoshu"};
    public static  String[] name2s = {"玉米","水稻","其他","果树"};
    public static  String[] colors = {"#CD0000","#228B22","#B4B9B8","#FFBD01"};

    public static Integer getCropTypeIndex(String cropType){
        for(int i=0;i<cropTypes.length;i++){
            if(cropTypes[i].equals(cropType)){
                return i;
            }
        }
        return null;
    }

    public static String castName(String name){
        for(int i = 0; i< cropTypes.length; i++){
            if(cropTypes[i].equals(name)){
                return name2s[i];
            }
        }
        return "";
    }
    public static String castColor(String name){
        for(int i = 0; i< cropTypes.length; i++){
            if(cropTypes[i].equals(name)){
                return colors[i];
            }
        }
        return "";
    }
}
