From f4a4f8a8cbd6a6277eff2cf9eb7cc48c35e99474 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Wed, 3 Dec 2014 13:14:19 +0800 Subject: Moved helper function's ownership --- aux/Card.java | 26 ++++++++++++++++++++++++++ engine/Action.java | 10 ++++++++++ player/PlayerAction.java | 7 ------- player/human/LocalHuman.java | 35 +++++++---------------------------- 4 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 engine/Action.java delete mode 100644 player/PlayerAction.java diff --git a/aux/Card.java b/aux/Card.java index cabd2d9..c84b9bb 100644 --- a/aux/Card.java +++ b/aux/Card.java @@ -1,5 +1,9 @@ package mahjong.aux; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + /** * Created by joe on 12/1/14. */ @@ -137,4 +141,26 @@ public class Card { public boolean isZi() { return isFeng() || isYuan(); } public boolean is19() { return isLaoTou() || isZi();} public boolean isZhongZhang(){ return !is19(); } + + public static Card readCardFromInput() + { + BufferedReader br = new BufferedReader(new + InputStreamReader(System.in)); + String cardStr="Yi Wan"; + try { + cardStr = br.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + return new Card(cardStr); + } + + // TODO This way of input will certainly kill users + public static Card[] readMultipleCardFromInput(int num) + { + Card[] res=new Card[num]; + for (int i=0;i