package com.LargeOrSmall;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Player {
//玩家属性
private int ID;
private String Name;
private List<Card> CardInHand;
//玩家方法
Player(){
ID=0;
Name=null;
CardInHand=new ArrayList<Card>();
}
//****************************
//玩家ID的输入输出
public void SetPlayerID(){
Scanner input=new Scanner(System.in);
while(true){
try{
System.out.println("请输入用户id:");
this.ID=input.nextInt();
break;
}catch(Exception e){
System.out.println("请输入整形数字作为ID!");
input=new Scanner(System.in);
continue;
}
}
input.close();
}
public int PutPlayerID(){
return ID;
}
//****************************
//玩家姓名的输入输出
public void SetPlayeName(){
Scanner input=new Scanner(System.in);
String name=new String();
name=input.next();
this.Name=name;
input.close();
}
public String PutPlayerName(){
return Name;
}
//******************************
//玩家现有手牌的输入输出
public void GetCardInHand(Card newCard){
CardInHand.add(newCard);
}
public void PutCardInHand(){
int i=0;
for (Card card : CardInHand) {
System.out.println("第"+(i++)+"张手牌为:"+card.PutColour()+card.PutNum());
}
}
public static void main(String[] args) {
Player a=new Player();
a.SetPlayerID();
a.SetPlayeName();
System.out.println(a.PutPlayerID());
}
}
添加回答
举报
0/150
提交
取消