import java.util.*;

public class Server {
  protected TransactionReport t = new TransactionReport();
  protected ManagerList m = new ManagerList();
  protected CustomerList c = new CustomerList();

  public Server() {
  }

  public boolean validManager(long id, long pin) {
    return m.authorizeManager(id, pin);
  }

  public void createAccount(long id, long pin) {
    if( (id / 1000000 / 100000) == 9 ) {
      m = new ManagerList(id, id, pin);
      m.addManager();
    } else {
      c = new CustomerList(id, id, pin);
      c.addCustomer();
    }
  }

  public void search(long ayear, long amon, long aday, long byear, long bmon, long bday) {
    t.searchDate(new Date((int)ayear, (int)amon, (int)aday), new Date((int)byear, (int)bmon, (int)bday));
  }

  public void processTransaction(long type, long id, long pin, long acctno,
                                 long othacct, long amount) {
    String desc;

    if (!c.authorizeCustomerNo(id, pin)) {
      System.out.print("Invalid ID.\n\n");
    } else {
      switch((int)type) {
      case 1:
        t = new TransactionReport(acctno, id, "W", amount, 0/*c.changeBalance(id, acctno, -amount)*/);
        t.addTransaction();
        break;
      case 2:
        t = new TransactionReport(acctno, id, "D", amount, 0/*c.changeBalance(id, acctno, amount)*/);
        t.addTransaction();
        break;
      case 3:
        t = new TransactionReport(acctno, id, "PB", amount, 0/*c.changeBalance(id, acctno, -amount)*/);
        t.addTransaction();
        break;
      case 4:
        /*c.ChangeBalance(id, othacct, amount);*/
        t = new TransactionReport(acctno, othacct, id, "TF", amount, 0/*c.ChangeBalance(id, acctno, -amount)*/);
        t.addTransaction();
        break;
      }
    }
  }
}