Ejemplo n.º 1
1
 void sortTransactionByDate() {
   List<Transaction> tr = new ArrayList<Transaction>(transactions.values());
   tr.sort(Transaction.DateComparator);
   for (Transaction t : tr) {
     t.displayTransaction();
   }
 }
Ejemplo n.º 2
1
 void sortbyAccount() {
   List<Accounts> ac = new ArrayList<Accounts>(accounts.values());
   ac.sort(Accounts.AccountComparator);
   for (Accounts a : ac) {
     a.dispaly();
   }
 }
Ejemplo n.º 3
0
 void searchAccountByBalance() {
   System.out.println(
       "\nEnter your Choice\n1.Exact Balance\n2.More than Balance\n3.Less than Balance\n4.Balance Range");
   Scanner in = new Scanner(System.in);
   int amount;
   int choice = in.nextInt();
   boolean flag = true;
   switch (choice) {
     case 1:
       System.out.println("Enter the Amount to be search");
       amount = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance == amount) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     case 2:
       System.out.println("Enter the Amount to be search for equal and more");
       amount = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance >= amount) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     case 3:
       System.out.println("Enter the Amount to be search for equal and less");
       amount = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance <= amount) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     case 4:
       System.out.println("Enter the Amount range\nMinimum:");
       amount = in.nextInt();
       System.out.println("Maximum:");
       int max = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance >= amount && a.balance <= max) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     default:
       System.out.println("Worn Input");
   }
 }
Ejemplo n.º 4
0
 void sortAccountByType() {
   List<Accounts> ac = new ArrayList<Accounts>(accounts.values());
   ac.sort(Accounts.TypeComparator);
   ac.stream()
       .forEach(
           (a) -> {
             a.dispaly();
           });
 }
Ejemplo n.º 5
0
 void sortAccountByCustomer() {
   List<Customer> cl = new ArrayList<Customer>(customers.values());
   cl.sort(Customer.CustomerComparatorByName);
   for (Customer c : cl) {
     System.out.println("Customer Name: " + c.CustomerName);
     Accounts a = accounts.get(c.AccountId);
     a.dispaly();
   }
 }
Ejemplo n.º 6
0
 void editTransaction() {
   System.out.println("Enter the transaction Id to be Edit");
   Scanner in = new Scanner(System.in);
   int tid = in.nextInt();
   for (Transaction t : transactions.values()) {
     if (tid == t.getTransactionId()) {
       t.editTransaction();
     }
   }
 }
Ejemplo n.º 7
0
 void displayAccounts() {
   // System.out.println("\nAccount List <account numbers>");
   accounts
       .values()
       .stream()
       .forEach(
           (acc) -> {
             acc.dispaly();
             // System.out.println("Account number: "+acc.AccountID);
           });
 }
Ejemplo n.º 8
0
 void deleteTransaction() {
   System.out.println("Enter the transaction Id to be delete");
   Scanner in = new Scanner(System.in);
   int tid = in.nextInt();
   for (Customer c : customers.values()) {
     for (int t : c.TransactionId) {
       if (t == tid) {
         c.TransactionId.remove(t);
         transactions.remove(t);
       }
     }
   }
 }
Ejemplo n.º 9
0
 void searchAccountByCustomerName() {
   Scanner in = new Scanner(System.in);
   boolean search = false;
   System.out.println("Enter Name Of the Customer:");
   String s = in.next();
   for (Customer c : customers.values()) {
     if (s.equals(c.CustomerName)) {
       search = true;
       accounts.get(c.AccountId).dispaly();
     }
   }
   if (!search) {
     System.out.println("Customer Not Found");
   }
 }
Ejemplo n.º 10
0
  void transactionBetween() {
    Scanner in = new Scanner(System.in);
    Date after;
    Date before;
    String expectedPattern = "MM/dd/yyyy";
    SimpleDateFormat formatter = new SimpleDateFormat(expectedPattern);
    try { // (2) give the formatter a String that matches the SimpleDateFormat pattern
      System.out.println("Enter Account Number");
      int acc = in.nextInt();
      boolean search = false;
      Customer cust = null;
      for (Customer c : customers.values()) {
        if (c.AccountId == acc) {
          search = true;
          cust = c;
        }
      }
      if (!search) {
        System.out.println("Account Not Found");
        return;
      }
      System.out.println("Enter Starting Date in MM/dd/yyyy format");
      String userInput = in.next();
      after = formatter.parse(userInput);
      System.out.println("Enter Starting Date in MM/dd/yyyy format");
      userInput = in.next();
      before = formatter.parse(userInput);
      for (int t : cust.TransactionId) {
        Transaction trans = transactions.get(t);
        if (trans.getDt().after(before) && trans.getDt().before(after)) trans.displayTransaction();
      }

    } catch (Exception e) {
      System.out.println(e.toString());
    }
  }