我想在我的纸牌游戏中为我的Card
课程的构造函数指定一个ouputstream。
实例化对象的类应该决定将cardobject分配给哪个流
它可以是输出到用户控制台的输出流
或者分配给套接字的流
如何弄清楚?我有这个:
public class SimplePlayCard {
private String cardType;
private int cardValue;
public OutputStream output;
public SimplePlayCard(String cardType, int cardValue, OutputStream output){
this.output = output;
}
public void toDisplay(){
output.println("This cardtype: " + this.cardType );
}
}
然后我想做
SimplePlayCard a = new SimplePlayCard("spades",1, System.out);
或
SimplePlayCard a = new SimplePlayCard("spades",1, stream connected to a socket);