ID3 Java Enum Tree

后端 未结 2 501
名媛妹妹
名媛妹妹 2021-01-27 15:06

I\'m trying to make a non-binary learning tree that\'s a simplified version of the ID3 algorithm. To do this, I tried to use enums, because there are several references teachin

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-27 15:46

    you can add a child class to features:

    import java.util.*;
    interface hasEnumChildren {
        Class clazz();
    }
    enum fuelstats {
        notempty,empty
    }
    enum lightstatus {
        Dim,Normal
    }
    enum scents {
        normal,gas
    }
    enum soundstatus {
        Normal,Howl,Screech,Click
    }
    enum turn {
        no,yes
    }
    enum problems {
        battery,starter,solenoid,outofgas,flooding
    }
    enum features implements hasEnumChildren {
        lightstatus(lightstatus.class),soundstatus(soundstatus.class),fuelstats(fuelstats.class),scents(scents.class),turn(turn.class),problems(problems.class);
        features(Class clazz) {
            this.clazz=clazz;
        }
        final Class clazz;
        @Override public Class clazz() {
            return clazz;
        }
    }
    public class So10233099 {
        public static void main(String[] args) {
            System.out.println(Arrays.asList(features.lightstatus.clazz().getEnumConstants()));
        }
    }
    

提交回复
热议问题