import java.io.*;

public class CompanyResponse {
	private Card card;
	private boolean status;

	public boolean getStatus() { return status; }
	public Card getCard() { return card; }
	
	public CompanyResponse(boolean status) {
		this.status = status;
		this.card = null;
	}
	
	public CompanyResponse(Card card) {
		this.status = (card != null);
		this.card = card;
	}
	
	public CompanyResponse(DataInputStream din) throws IOException {
		status = din.readBoolean();
		
		boolean isCard = din.readBoolean();
		
		if (isCard)
			card = new Card(din);
		else
			card = null;
	}


	public void write(DataOutputStream dout) throws IOException {
		dout.writeBoolean(status);
		
		if (card != null) {
			dout.writeBoolean(true);
			card.write(dout);
		}
		else
			dout.writeBoolean(false);
	}
}
