import java.io.*;

import java.io.*;

public class CompanyRequest {
	public static final int ISSUE = 1001;
	public static final int FIND_BY_NAME =1002;
	public static final int FIND_BY_NUMBER = 1003;
	public static final int PURCHASE = 1004;
	public static final int PAYMENT = 1005;
	public static final int CANCEL = 1006;
	public static final int HANG_UP = 3000;

	private int type;
	private String name = "";
	private int number;
	private String item = "";
	private double amount;

	public int getType() { return type; }
	public String getName() { return name; }
	public int getNumber() { return number; }
	public String getItem() { return item; }
	public double getAmount() { return amount; }

	
	private CompanyRequest(int type) {
		this.type = type;
	}

	public CompanyRequest(DataInput din) throws IOException {
		type = din.readInt();
		name = din.readUTF();
		number = din.readInt();
		item = din.readUTF();
		amount = din.readDouble();
	}

	public void write(DataOutput dout) throws IOException  {
		dout.writeInt(type);
		dout.writeUTF(name);
		dout.writeInt(number);
		dout.writeUTF(item);
		dout.writeDouble(amount);
	}
	
	public static CompanyRequest createIssueRequest(String name) {
		CompanyRequest rq = new CompanyRequest(ISSUE);
		rq.name = name;
		return rq;
	}
	
	public static CompanyRequest createFindRequest(String name) {
		CompanyRequest rq = new CompanyRequest(FIND_BY_NAME);
		rq.name = name;
		return rq;
	}

	public static CompanyRequest createFindRequest(int number) {
		CompanyRequest rq = new CompanyRequest(FIND_BY_NUMBER);
		rq.number = number;
		return rq;
	}

	public static CompanyRequest createCancelRequest(int number){
		CompanyRequest rq = new CompanyRequest(CANCEL);
		rq.number = number;
		return rq;
	}
	
	public static CompanyRequest createPurchaseRequest(int number, String item, double amount) {
		CompanyRequest rq = new CompanyRequest(PURCHASE);
		rq.number = number;
		rq.item = item;
		rq.amount = amount;
		return rq;
	}
		
	public static CompanyRequest createPaymentRequest(int number, double amount) {
		CompanyRequest rq = new CompanyRequest(PAYMENT);
		rq.number = number;
		rq.amount = amount;
		return rq;
	}
	
	public static CompanyRequest createHangUpRequest(){
		CompanyRequest rq = new CompanyRequest(HANG_UP);
		return rq;
	}
}
