1. 程式人生 > >Java 枚舉和抽象類添加狀態值

Java 枚舉和抽象類添加狀態值

trac final 抽象類 brush light ava esc turn The

枚舉:

public enum CourseTypeEnum {
    VIDEO_COURSE(1,"錄制課程"),
    LIVE_COURSE(2,"直播課程"),
    OFFINE_COURSE(3,"線下課程");
    private int seq;
    private  String desc;
    CourseTypeEnum(int seq,String desc){
        this.seq=seq;
        this.desc=desc;
    }
    public int getSeq(){
        return seq;
    }
    public String gtDesc(){
        return desc;
    }
}

  抽象類:

public abstract class BaseCourseState {
    public static  final  int NEW_COURSE=1;
    public static  final  int UNAUTHED_COURSE=2;
    public static  final int PASSED_COURSE=3;
    public static  final int NOT_PASSED_COURSE=4;
    public static final int DELETED_COURSE=5;
}

  調用:

public class Test {
    public static void main(String[] args) {
        public void getPackgeCourse(Long packageId,Long userId){
           if(packageId==CourseTypeEnum.OFFINE_COURSE.getSeq()){
               return;
           }
           if(course.getState==BaseCourseState.UNAUTHED_COURSE){
               return ;
           }
        }
    }
}

  

Java 枚舉和抽象類添加狀態值