diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..62bdf20 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..a9fd48a --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + ATM-Management-System-Maintenance-Project + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1768836522542 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/README.md b/README.md index 7a5b30d..82c9795 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ This repository contains an ATM Management System project implemented in Java. ## Instructions -To run the program, follow these steps: +To run the program, follow these steps: -- -1. Run the `AtmMainDriver` file. +1. Run the `AtmMainDriver` file. 2. No additional packages need to be downloaded. 3. The username and password for both "Admin" and "User" are as follows: - Username: zahid diff --git a/atm/bin/atm/AccountData.class b/atm/bin/atm/AccountData.class new file mode 100644 index 0000000..ff995f1 Binary files /dev/null and b/atm/bin/atm/AccountData.class differ diff --git a/atm/bin/atm/Admin.class b/atm/bin/atm/Admin.class new file mode 100644 index 0000000..4b767b5 Binary files /dev/null and b/atm/bin/atm/Admin.class differ diff --git a/atm/bin/atm/AfterLogin.class b/atm/bin/atm/AfterLogin.class new file mode 100644 index 0000000..9e3b196 Binary files /dev/null and b/atm/bin/atm/AfterLogin.class differ diff --git a/atm/bin/atm/AtmMainDriver.class b/atm/bin/atm/AtmMainDriver.class new file mode 100644 index 0000000..d3bfa60 Binary files /dev/null and b/atm/bin/atm/AtmMainDriver.class differ diff --git a/atm/bin/atm/LoginForm.class b/atm/bin/atm/LoginForm.class new file mode 100644 index 0000000..917258e Binary files /dev/null and b/atm/bin/atm/LoginForm.class differ diff --git a/atm/bin/atm/TestTransactionHistory.class b/atm/bin/atm/TestTransactionHistory.class new file mode 100644 index 0000000..9d61c2e Binary files /dev/null and b/atm/bin/atm/TestTransactionHistory.class differ diff --git a/atm/build/classes/atm/AccountData.class b/atm/build/classes/atm/AccountData.class index 63e2f61..cf427aa 100644 Binary files a/atm/build/classes/atm/AccountData.class and b/atm/build/classes/atm/AccountData.class differ diff --git a/atm/build/classes/atm/Admin.class b/atm/build/classes/atm/Admin.class index 41f6dd1..0783623 100644 Binary files a/atm/build/classes/atm/Admin.class and b/atm/build/classes/atm/Admin.class differ diff --git a/atm/build/classes/atm/AfterLogin.class b/atm/build/classes/atm/AfterLogin.class index 42bdefe..1e3f39d 100644 Binary files a/atm/build/classes/atm/AfterLogin.class and b/atm/build/classes/atm/AfterLogin.class differ diff --git a/atm/build/classes/atm/AtmMainDriver.class b/atm/build/classes/atm/AtmMainDriver.class index 0357465..0da7eea 100644 Binary files a/atm/build/classes/atm/AtmMainDriver.class and b/atm/build/classes/atm/AtmMainDriver.class differ diff --git a/atm/build/classes/atm/LoginForm$ATM_System.class b/atm/build/classes/atm/LoginForm$ATM_System.class deleted file mode 100644 index 44cf94b..0000000 Binary files a/atm/build/classes/atm/LoginForm$ATM_System.class and /dev/null differ diff --git a/atm/build/classes/atm/LoginForm.class b/atm/build/classes/atm/LoginForm.class index c6d6812..d77e5f1 100644 Binary files a/atm/build/classes/atm/LoginForm.class and b/atm/build/classes/atm/LoginForm.class differ diff --git a/atm/build/classes/atm/TestTransactionHistory.class b/atm/build/classes/atm/TestTransactionHistory.class new file mode 100644 index 0000000..c029fa9 Binary files /dev/null and b/atm/build/classes/atm/TestTransactionHistory.class differ diff --git a/atm/src/atm/Admin.java b/atm/src/atm/Admin.java index 7e4e6a4..c22a146 100644 --- a/atm/src/atm/Admin.java +++ b/atm/src/atm/Admin.java @@ -2,9 +2,9 @@ import java.awt.Color; import java.awt.Container; import java.awt.event.*; +import java.io.*; import java.util.*; import javax.swing.*; -import java.io.*; /*\ I have to add these options Add Account @@ -23,7 +23,7 @@ public class Admin extends JFrame implements ActionListener JLabel atmLab; Container con; ArrayList customerlist; - String s1,s2,s3; + String s1; Admin() { super("ADMIN"); @@ -67,7 +67,42 @@ public class Admin extends JFrame implements ActionListener saveToFile.addActionListener(this); logOut.addActionListener(this); + loadPersons(); + } + /*******************************LOAD ACCOUNT FROM FILE*******************************************/ + public void loadPersons() + { + String ss[]=null; + String pincode,customername,accounttype,accountnumber,startbalance; + + try + { + FileReader fr=new FileReader("Customer Record.txt"); + BufferedReader br=new BufferedReader(fr); + + String line=br.readLine(); + + while(line != null) + { + ss=line.split(","); + pincode=ss[0]; + customername=ss[1]; + accounttype=ss[2]; + accountnumber=ss[3]; + startbalance=ss[4]; + + AccountData atm=new AccountData(pincode,customername,accounttype,accountnumber,startbalance); + customerlist.add(atm); + line=br.readLine(); + } + br.close(); + fr.close(); + } + catch(IOException ioEX) + { + System.out.println("No existing customer records found. Starting fresh."); + } } /*******************************ADD ACCOUNT************************************************/ @@ -218,6 +253,7 @@ public void edit(String n) /************************************************************************************************************/ /***************************************************************************************************/ + @Override public void actionPerformed(ActionEvent e) { diff --git a/atm/src/atm/AfterLogin.java b/atm/src/atm/AfterLogin.java index fe8a76a..1068561 100644 --- a/atm/src/atm/AfterLogin.java +++ b/atm/src/atm/AfterLogin.java @@ -1,19 +1,19 @@ package atm; import java.awt.*; import java.awt.event.*; +import java.io.*; import java.util.*; import javax.swing.*; -import java.io.*; public class AfterLogin extends JFrame implements ActionListener { - JButton equiryBtn,withdrawBtn,logoutBtn,transferBtn; + JButton equiryBtn,withdrawBtn,logoutBtn,transferBtn,transactionHistoryButton; JLabel atmLab; Container con; ArrayList customerlist; - Admin adm = new Admin(); String s1; + String pincode; AfterLogin() { @@ -38,7 +38,10 @@ public class AfterLogin extends JFrame implements ActionListener withdrawBtn = new JButton("WithDraw Money"); withdrawBtn.setBounds(260,230,150,40); - + transactionHistoryButton = new JButton("Transaction History"); + transactionHistoryButton.setBounds(200,300,180,30); + transactionHistoryButton.setFont(new Font("Arial", Font.BOLD, 14)); + logoutBtn = new JButton("Logout"); logoutBtn.setBounds(10,230,150,40); @@ -46,12 +49,14 @@ public class AfterLogin extends JFrame implements ActionListener con.add(equiryBtn); con.add(withdrawBtn); con.add(transferBtn); + con.add(transactionHistoryButton); con.add(logoutBtn); /********************************************************************/ equiryBtn.addActionListener(this); transferBtn.addActionListener(this); withdrawBtn.addActionListener(this); + transactionHistoryButton.addActionListener(this); logoutBtn.addActionListener(this); loadPersons(); @@ -95,19 +100,79 @@ public void loadPersons() /***************************************************************************************************************************/ +/********************************************************* Transaction Logging Method *************************************/ +private void logTransaction(String type, double amount, double newBalance) { + String filename = "transactions_" + this.pincode + ".txt"; + try { + FileWriter fw = new FileWriter(filename, true); + BufferedWriter bw = new BufferedWriter(fw); + + // Get current timestamp + java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String timestamp = sdf.format(new java.util.Date()); + + // Write transaction details + bw.write(type + " | " + amount + " | " + newBalance + " | " + timestamp); + bw.newLine(); + bw.close(); + fw.close(); + } catch(IOException ioEX) { + System.out.println(ioEX); + } +} + +/***************************************************************************************************************************/ + +/********************************************************* View Transaction History *************************************/ +public void viewTransactionHistory(String pincode) { + String filename = "transactions_" + pincode + ".txt"; + try { + FileReader fr = new FileReader(filename); + BufferedReader br = new BufferedReader(fr); + + ArrayList transactions = new ArrayList<>(); + String line = br.readLine(); + + while(line != null) { + transactions.add(line); + line = br.readLine(); + } + br.close(); + fr.close(); + + // Display last 10 transactions + StringBuilder history = new StringBuilder(); + int start = Math.max(0, transactions.size() - 10); + + if(transactions.isEmpty()) { + history.append("No transactions found."); + } else { + history.append("Last ").append(Math.min(10, transactions.size())).append(" Transactions:\n\n"); + for(int i = start; i < transactions.size(); i++) { + history.append(transactions.get(i)).append("\n"); + } + } + + JOptionPane.showMessageDialog(null, history.toString(), "Transaction History", JOptionPane.INFORMATION_MESSAGE); + } catch(IOException ioEX) { + JOptionPane.showMessageDialog(null, "No transaction history found for this account.", "Transaction History", JOptionPane.INFORMATION_MESSAGE); + } +} + +/***************************************************************************************************************************/ + + +/********************************************************* Balance Enquiry of Customer ************************************/ + private void inquiry(String k) { + for(int i=0;i lines = new ArrayList<>(); + String line; + while ((line = br.readLine()) != null) lines.add(line); + br.close(); + + int start = Math.max(0, lines.size() - 10); + System.out.println("\nLast " + Math.min(10, lines.size()) + " transactions:"); + for (int i = start; i < lines.size(); i++) { + System.out.println(lines.get(i)); + } + } catch (IOException e) { + System.out.println("Failed to read transactions: " + e); + e.printStackTrace(); + } + } +} diff --git a/atm/transactions_1234.txt b/atm/transactions_1234.txt new file mode 100644 index 0000000..860dd06 --- /dev/null +++ b/atm/transactions_1234.txt @@ -0,0 +1,12 @@ +Deposit | 101 | 1001 | 2026-02-05 23:57:24 +Deposit | 102 | 1002 | 2026-02-05 23:57:24 +Deposit | 103 | 1003 | 2026-02-05 23:57:24 +Deposit | 104 | 1004 | 2026-02-05 23:57:24 +Deposit | 105 | 1005 | 2026-02-05 23:57:24 +Deposit | 106 | 1006 | 2026-02-05 23:57:24 +Deposit | 107 | 1007 | 2026-02-05 23:57:24 +Deposit | 108 | 1008 | 2026-02-05 23:57:24 +Deposit | 109 | 1009 | 2026-02-05 23:57:24 +Deposit | 110 | 1010 | 2026-02-05 23:57:24 +Deposit | 111 | 1011 | 2026-02-05 23:57:24 +Deposit | 112 | 1012 | 2026-02-05 23:57:24