I want to assign an ouputstream to the constructor of my Card
class in my card game.
The class that instantiates the object should decide which stream to assign the the cardobject to.
It could be the outputstream that goes to the user console
or to a stream that is assigned to a socket.
How to get it correct? I have this:
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 );
}
}
Then I want to do
SimplePlayCard a = new SimplePlayCard("spades",1, System.out);
or
SimplePlayCard a = new SimplePlayCard("spades",1, stream connected to a socket);