日期:2014-05-20 浏览次数:21053 次
public interface People { public void freedom(); public void democratic(); public void democratic(Country parade); public void likeGovernment(int like); }
public final class Chinese implements People { public static final Chinese chinese=new Chinese(); private Chinese() {}; public void freedom() { throw new UnsupportedOperationException(); } public void democratic() { throw new UnsupportedOperationException(); } public void likeGovernment(int like) { if(like<100) { throw new IllegalArgumentException("only 100 support"); } } public void democratic(Country parade) { if(parade!=Country.CHINA&¶de!=Country.NORTH_KOREA) { if(new Random().nextBoolean()) { // justdo(); }else { throw new IllegalStateException(); } }else { throw new UnsupportedOperationException(); } } @Override public String toString() { return "我是中国人我自豪"; } }