greenhandc
2015-12-14 13:07
import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class Gameplay { List<Poker>pokerlist=new ArrayList<Poker>(); List<Player>playerlist=new ArrayList<Player>(); String[]type={"方块","梅花","红桃","黑桃"}; String[]point={"2","3","4","5","6","7","8","9","10","J","Q","K","A"}; /** * 首先创建的是一副扑克牌 */ public void creatPoker(){ System.out.println("开始创建扑克牌"); for(int i=0;i<type.length;i++){ for(int j=0;j<point.length;j++){ pokerlist.add(new Poker(type[i],point[j])); } System.out.println("扑克牌创建成功"); } } /** * 检验扑克牌是否完成 */ public void testCreatPoker(){ for(Poker pk:pokerlist){ System.out.println("有如下牌:"+pk.toString()+" ");} } /** * 然后是创建2个玩家 */ public void creatPlayer(){ for(int n=0;n<2;n++){ System.out.println("请输入玩家ID"); String playerID=new Scanner(System.in).next(); System.out.println("请输入玩家姓名"); String playerName=new Scanner(System.in).next(); playerlist.add(new Player(playerID,playerName)); } System.out.println("玩家添加成功!"+"现有玩家是:"); for(Player player:playerlist){ System.out.println(player.getID()+":"+player.getName()); } } /** * 检验扑克牌是否完成 */ public void testcreatpoker(){ for(Poker poker:pokerlist){ System.out.println(poker.getType()+poker.getNum()); } } /** * * @param args */ public static void main(String [] args){ Gameplay t1=new Gameplay(); t1.creatPlayer(); t1.testCreatPoker(); } }
是不是因为没有调用过creatPoker方法所以没创建过扑克牌
Java入门第三季
409792 学习 · 4340 问题
相似问题