import java.awt.*;
import java.util.*;

class CompanyPresentation extends Panel{
	CompanyTransactionProxy parent;
	CardSearch search = new CardSearch(this);
	CardData   data = new CardData();
	CardControl control = new CardControl(this);
	
	CompanyPresentation(CompanyTransactionProxy app) {
		parent = app;

		setLayout(new BorderLayout());
		add("North", search);
		add("Center", data);
		add("South", control);
	}

	void issueCard() {
		String name = data.getName();
		Card card = parent.issueCard(name);

		data.display(card);
	}

	void findCardByName() {
		String name = data.getName();
		Card card = parent.findCard(name);
		data.display(card);
	}

	void findCardByNumber() {
		int number = data.getNumber();
		Card card = parent.findCard(number);
		data.display(card);
	}

	void cancelCard() {
		int number = data.getNumber();
		if (parent.cancelCard(number))
			data.clearData();
	}

	void purchase() {
		int number = data.getNumber();
		String item = data.getItem();
		double amount = data.getAmount();
		Card card = parent.purchase(number, item, amount);
		data.display(card);
	}

	void payment() {
		int number = data.getNumber();
		double amount = data.getAmount();
		Card card = parent.payment(number, amount);
		data.display(card);
	}
}
