枚举 猜拳游戏

时间:2022-02-04 05:29:16
【文件属性】:

文件名称:枚举 猜拳游戏

文件大小:5KB

文件格式:ZIP

更新时间:2022-02-04 05:29:16

java 枚举 多路并发

package 猜拳游戏; import static 猜拳游戏.OutCome.*; public enum RoshamBo2 implements Competitor { PAPER(DRAW, LOSE, WIN){ @Override public String toString() { return "布 "; } }, SCISSORS(WIN, DRAW, LOSE) { @Override public String toString() { return "剪刀"; } }, ROCK(LOSE, WIN, DRAW) { @Override public String toString() { return "石头"; } }; public abstract String toString(); private OutCome vPAPER, vSICISSOR, vROCK; RoshamBo2(OutCome paper, OutCome scissors, OutCome rcok){ this.vPAPER = paper; this.vSICISSOR = scissors; this.vROCK = rcok; } @Override public OutCome compete(RoshamBo2 it) { switch (it){ default: return null; case PAPER:return vPAPER; case SCISSORS:return vSICISSOR; case ROCK:return vROCK; } } public static void main(String [] argv){ RoShamBo.play(RoshamBo2.class, 20); } }


【文件预览】:
猜拳游戏
----OutCome.java(507B)
----RoShamBo3.java(1KB)
----Competitor.java(133B)
----Enums.java(318B)
----RoShamBo4.java(822B)
----RoshamBo2.java(1KB)
----RoShamBo.java(422B)
----RoShamBo5.java(1KB)
----RoShamBo6.java(541B)
----RoshamBo1.java(2KB)

网友评论