package com.javasort;
/**
*一个类只能有四个固定的对象 且属性固定的实现
*/
public class Season {
private final String SEASON_NAME;
private final String SEASON_DESC;
private Season(String seansonName, String seansonDesc) {
//super();
this.SEASON_NAME = seansonName;
this.SEASON_DESC = seansonDesc;
}
static final Season spring=new Season("春天","春风吹过大地");
static final Season summer =new Season("夏天","骄阳似火");
static final Season autumn =new Season("秋天","秋水共长天一色");
static final Season winter =new Season ("冬天","千树万树梨花开");
public String getSEASON_NAME() {
return SEASON_NAME;
}
public String getSEASON_DESC() {
return SEASON_DESC;
}
}
自己封装的类,模仿枚举类
时间: 2024-10-17 04:38:13