问答详情
源自:7-1 什么是 Java 中的封装

请问这个怎么简化

private float scerr;

private float cpu;

private float mem;

public float getScerr(){

return scerr;

}

public float getCpu(){

return cpu;

}

public float getMem(){

return mem;

}

public void setScerr(float newScerr){

scerr =newScerr;

}

public void setCpu(float setCpu){

cpu =setCpu;

}

public void setMem(float setMem){

mem =setMem;

}


提问者:qq_龙之子_1 2018-07-17 16:37

个回答

  • 慕慕3157912
    2018-07-17 17:12:26

    private float scerr;

    private float cpu;

    private float mem;


    public float getScerr(){

    return scerr;

    }

    public float getCpu(){

    return cpu;

    }

    public float getMem(){

    return mem;

    }

    public void setScerr(float scerr){

    this.scerr =scerr;

    }

    public void setCpu(float cpu){

    this.cpu =cpu;

    }

    public void setMem(float mem){

    this.mem =mem;

    }