-CoderOilStation 课程类别:计算机 课程名:CPSC110 系统程序设计环节 Systematic Program Design

38 阅读1分钟

-CoderOilStation

 

课程类别:计算机

课程名:CPSC110 系统程序设计环节 Systematic Program Design

step_rectangel_20250613092538.png

Java-solution

public static Boolean drawRectanguleIntervalByBottomBlank(int stepInts,BottomBlank bottomBlank){
    if (stepInts<0 || stepInts>9){
        return null;
    }
    if (bottomBlank==null){
        return null;
    }
    ArrayList<Ractangle> ractangleArrayList = new ArrayList<>();
    for (int i = 0; i < stepInts; i++) {
        Ractangle ractangle = new Ractangle();
        ractangle.setId(UUID.randomUUID().toString());
        ractangle.setName("blueRactangle"+i);
        ractangle.setWidth(1);
        ractangle.setHeight(i+1);
        ractangleArrayList.add(ractangle);
    }
    ArrayList<BottomBlank> bottomBlankArrayList = new ArrayList<>();
    for (int i = 0; i < stepInts; i++) {
        BottomBlank bottomBlank1 = new BottomBlank();
        bottomBlank1.setId(UUID.randomUUID().toString());
        bottomBlankArrayList.add(bottomBlank1);
    }

    for (int i = 0; i < stepInts; i++) {
        System.out.println(ractangleArrayList.get(i).toString());
        System.out.println(bottomBlankArrayList.get(i).toString());
    }
    return true;
}

enum Color{
    BLUE("0001","blue")
        ,WHITE("0002","white");
    private String key;
    private String val;

    Color(String key, String val){
        this.key = key;
        this.val = val;
    }
    public String getKey() {
        return key;
    }
    public String getVal() {
        return val;
    }
}
class Ractangle{
    private String id;
    private String name;
    private Integer width;
    private Integer height;
    private String ractangleColor=Color.BLUE.getVal();

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }

    public String getRactangleColor() {
        return ractangleColor;
    }

    public void setRactangleColor(String ractangleColor) {
        this.ractangleColor = ractangleColor;
    }

    @Override
    public String toString() {
        return "Ractangle{" +
                "id='" + id + ''' +
                ", name='" + name + ''' +
                ", width=" + width +
                ", height=" + height +
                ", ractangleColor='" + ractangleColor + ''' +
                '}';
    }
}

class BottomBlank{
    private String id;
    private final String BottomBlankColor=Color.WHITE.getVal();
    private Integer BottomBlankWidth=1;
    private Integer BottomBlankHeight=10;
    private final Integer BootomBlankDemesion=2;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getBottomBlankColor() {
        return BottomBlankColor;
    }

    public Integer getBottomBlankWidth() {
        return BottomBlankWidth;
    }

    public void setBottomBlankWidth(Integer bottomBlankWidth) {
        BottomBlankWidth = bottomBlankWidth;
    }

    public Integer getBottomBlankHeight() {
        return BottomBlankHeight;
    }

    public void setBottomBlankHeight(Integer bottomBlankHeight) {
        BottomBlankHeight = bottomBlankHeight;
    }

    public Integer getBootomBlankDemesion() {
        return BootomBlankDemesion;
    }

    @Override
    public String toString() {
        return "BottomBlank{" +
                "id='" + id + ''' +
                ", BottomBlankColor='" + BottomBlankColor + ''' +
                ", BottomBlankWidth=" + BottomBlankWidth +
                ", BottomBlankHeight=" + BottomBlankHeight +
                ", BootomBlankDemesion=" + BootomBlankDemesion +
                '}';
    }
}