ATM

public class ATM extends JFrame { private boolean DEBUG_KEYPAD = false; private int screenState; private Data user; private String tempEntry; private int moneyInMachine = 10000000; private int userBalance = 100; private int DEBUG_AMOUNT = 20; public static final String BANK = "Security Financial Corporation"; public static final String SOFTWARE_VERSION = "23.45.2.2"; public static final String SECURED_BY = "Verisign"; private static final int ASK_FOR_CARD = 1; private static final int AUTHENTICATION = 2; private static final int DISPLAY_ACCOUNTS = 3; private static final int AMOUNT_INPUT = 4; private static final int CHECK_BALANCE = 5; private static final int WIDTHDRAW_AMOUNT = 6; private static final int INSUFFICIENT = 7; private static final int DEBUG_SCREEN = 8; private static int SECRET_KEY = 15661; private static int SECRET_KEY_2 = 24623; private JLabel ATMLabel; private JPanel cardSlot; private JPanel cash; private JLabel cashamount; private JLayeredPane jLayeredPane1; private JPanel jPanel1; private JPanel jPanel3; private JPanel jPanel4; private JPanel jPanel5; private JPanel jPanel8; private JPanel jPanel9; private JScrollPane jScrollPane1; private JTextArea mainConsole; private JButton pin0; private JButton pin1; private JButton pin2; private JButton pin3; private JButton pin4; private JButton pin5; private JButton pin6; private JButton pin7; private JButton pin8; private JButton pin9; private JButton pinCancel; private JButton pinOK; private JPanel recieptSlot; private JButton scrn1; private JButton scrn2; private JButton scrn3; private JButton scrn4; private JButton scrn5; private JButton scrn6; private JButton scrn7; private JButton scrn8; public ATM() { this.initComponents(); this.initVariables(); } private void initComponents() { this.ATMLabel = new JLabel(); this.jPanel1 = new JPanel(); this.scrn1 = new JButton(); this.scrn5 = new JButton(); this.scrn6 = new JButton(); this.scrn7 = new JButton(); this.scrn8 = new JButton(); this.scrn2 = new JButton(); this.scrn3 = new JButton(); this.scrn4 = new JButton(); this.jScrollPane1 = new JScrollPane(); this.mainConsole = new JTextArea(); this.jPanel3 = new JPanel(); this.pin1 = new JButton(); this.pin2 = new JButton(); this.pin3 = new JButton(); this.pin4 = new JButton(); this.pin5 = new JButton(); this.pin6 = new JButton(); this.pin7 = new JButton(); this.pin8 = new JButton(); this.pinCancel = new JButton(); this.pinOK = new JButton(); this.pin9 = new JButton(); this.pin0 = new JButton(); this.jLayeredPane1 = new JLayeredPane(); this.cash = new JPanel(); this.cashamount = new JLabel(); this.jPanel4 = new JPanel(); this.cardSlot = new JPanel(); this.jPanel5 = new JPanel(); this.recieptSlot = new JPanel(); this.jPanel8 = new JPanel(); this.jPanel9 = new JPanel(); this.setDefaultCloseOperation(3); this.setBackground(new Color(153, 153, 153)); this.setName("ATM"); this.setResizable(false); this.ATMLabel.setBackground(new Color(0, 51, 255)); this.ATMLabel.setFont(new Font("Tahoma", 0, 36)); this.ATMLabel.setForeground(new Color(255, 255, 255)); this.ATMLabel.setHorizontalAlignment(0); this.ATMLabel.setText("Secure Financial Corp"); this.ATMLabel.setBorder(BorderFactory.createTitledBorder(null, "Keeping your money safe since 1832", 3, 5, new Font("Tahoma", 0, 14), new Color(255, 255, 255))); this.ATMLabel.setOpaque(true); this.jPanel1.setBackground(new Color(102, 102, 102)); this.jPanel1.setBorder(BorderFactory.createBevelBorder(0)); this.scrn1.setText("1>"); this.scrn1.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn1MouseClicked(mouseEvent); } }); this.scrn5.setText("<5"); this.scrn5.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn5MouseClicked(mouseEvent); } }); this.scrn6.setText("<6"); this.scrn6.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn6MouseClicked(mouseEvent); } }); this.scrn7.setText("<7"); this.scrn7.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn7MouseClicked(mouseEvent); } }); this.scrn8.setText("<8"); this.scrn8.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn8MouseClicked(mouseEvent); } }); this.scrn2.setText("2>"); this.scrn2.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn2MouseClicked(mouseEvent); } }); this.scrn3.setText("3>"); this.scrn3.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn3MouseClicked(mouseEvent); } }); this.scrn4.setText("4>"); this.scrn4.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.scrn4MouseClicked(mouseEvent); } }); this.mainConsole.setBackground(new Color(0, 0, 0)); this.mainConsole.setColumns(20); this.mainConsole.setEditable(false); this.mainConsole.setFont(new Font("Monospaced", 0, 14)); this.mainConsole.setForeground(new Color(255, 255, 255)); this.mainConsole.setLineWrap(true); this.mainConsole.setRows(8); this.mainConsole.setCaretColor(new Color(255, 255, 255)); this.mainConsole.setFocusable(false); this.jScrollPane1.setViewportView(this.mainConsole); GroupLayout groupLayout = new GroupLayout(this.jPanel1); this.jPanel1.setLayout(groupLayout); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, groupLayout.createSequentialGroup().addContainerGap(-1, 32767).addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.scrn1).addComponent(this.scrn2).addComponent(this.scrn3).addComponent(this.scrn4)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.jScrollPane1, -2, 367, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(this.scrn5).addComponent(this.scrn6).addComponent(this.scrn7).addComponent(this.scrn8)).addGap(59, 59, 59))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addContainerGap().addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addGap(0, 115, 32767).addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(this.scrn5).addComponent(this.scrn1)).addGap(18, 18, 18).addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addComponent(this.scrn2).addGap(18, 18, 18).addComponent(this.scrn3).addGap(18, 18, 18).addComponent(this.scrn4).addContainerGap()).addGroup(GroupLayout.Alignment.TRAILING, groupLayout.createSequentialGroup().addComponent(this.scrn6).addGap(18, 18, 18).addComponent(this.scrn7).addGap(18, 18, 18).addComponent(this.scrn8).addGap(41, 41, 41)))).addGroup(groupLayout.createSequentialGroup().addComponent(this.jScrollPane1).addContainerGap())))); this.jPanel3.setBackground(new Color(204, 204, 204)); this.jPanel3.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); this.pin1.setFont(new Font("Tahoma", 0, 10)); this.pin1.setText("1"); this.pin1.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin1MouseClicked(mouseEvent); } }); this.pin2.setFont(new Font("Tahoma", 0, 10)); this.pin2.setText("2"); this.pin2.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin2MouseClicked(mouseEvent); } }); this.pin3.setFont(new Font("Tahoma", 0, 10)); this.pin3.setText("3"); this.pin3.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin3MouseClicked(mouseEvent); } }); this.pin4.setFont(new Font("Tahoma", 0, 10)); this.pin4.setText("4"); this.pin4.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin4MouseClicked(mouseEvent); } }); this.pin5.setFont(new Font("Tahoma", 0, 10)); this.pin5.setText("5"); this.pin5.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin5MouseClicked(mouseEvent); } }); this.pin6.setFont(new Font("Tahoma", 0, 10)); this.pin6.setText("6"); this.pin6.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin6MouseClicked(mouseEvent); } }); this.pin7.setFont(new Font("Tahoma", 0, 10)); this.pin7.setText("7"); this.pin7.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin7MouseClicked(mouseEvent); } }); this.pin8.setFont(new Font("Tahoma", 0, 10)); this.pin8.setText("8"); this.pin8.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin8MouseClicked(mouseEvent); } }); this.pinCancel.setFont(new Font("Tahoma", 0, 10)); this.pinCancel.setText("X"); this.pinCancel.setMargin(new Insets(2, 0, 2, 0)); this.pinCancel.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pinCancelMouseClicked(mouseEvent); } }); this.pinOK.setFont(new Font("Tahoma", 0, 10)); this.pinOK.setText("OK"); this.pinOK.setMargin(new Insets(2, 2, 2, 2)); this.pinOK.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pinOKMouseClicked(mouseEvent); } }); this.pin9.setFont(new Font("Tahoma", 0, 10)); this.pin9.setText("9"); this.pin9.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin9MouseClicked(mouseEvent); } }); this.pin0.setFont(new Font("Tahoma", 0, 10)); this.pin0.setText("0"); this.pin0.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.pin0MouseClicked(mouseEvent); } }); GroupLayout groupLayout2 = new GroupLayout(this.jPanel3); this.jPanel3.setLayout(groupLayout2); groupLayout2.setHorizontalGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout2.createSequentialGroup().addContainerGap().addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING, false).addComponent(this.pin1, -1, -1, 32767).addComponent(this.pin7, GroupLayout.Alignment.TRAILING, -1, -1, 32767).addComponent(this.pin4, GroupLayout.Alignment.TRAILING, -1, -1, 32767).addComponent(this.pinOK, GroupLayout.Alignment.TRAILING, -1, -1, 32767)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout2.createSequentialGroup().addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.pin5, -1, -1, 32767).addComponent(this.pin8, -1, -1, 32767).addComponent(this.pin0, -1, -1, 32767)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout2.createSequentialGroup().addComponent(this.pin6).addGap(0, 0, 32767)).addComponent(this.pin9, -1, -1, 32767).addGroup(GroupLayout.Alignment.TRAILING, groupLayout2.createSequentialGroup().addGap(0, 0, 32767).addComponent(this.pinCancel, -2, 37, -2)))).addGroup(GroupLayout.Alignment.TRAILING, groupLayout2.createSequentialGroup().addComponent(this.pin2, -2, 37, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.pin3))).addContainerGap())); groupLayout2.setVerticalGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout2.createSequentialGroup().addContainerGap().addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.pin1).addComponent(this.pin2).addComponent(this.pin3)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.pin4).addComponent(this.pin5).addComponent(this.pin6)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.pin7).addComponent(this.pin8).addComponent(this.pin9)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(groupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.pinCancel).addComponent(this.pinOK).addComponent(this.pin0)).addContainerGap(12, 32767))); this.cash.setBackground(new Color(0, 153, 0)); this.cash.setVisible(false); this.cash.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.cashMouseClicked(mouseEvent); } }); GroupLayout groupLayout3 = new GroupLayout(this.cash); this.cash.setLayout(groupLayout3); groupLayout3.setHorizontalGroup(groupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout3.createSequentialGroup().addGap(128, 128, 128).addComponent(this.cashamount).addContainerGap(148, 32767))); groupLayout3.setVerticalGroup(groupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, groupLayout3.createSequentialGroup().addContainerGap(50, 32767).addComponent(this.cashamount).addGap(26, 26, 26))); this.cash.setBounds(20, 90, 310, 90); this.jLayeredPane1.add((Component)this.cash, JLayeredPane.DEFAULT_LAYER); this.jPanel4.setBackground(new Color(153, 153, 153)); this.jPanel4.setBorder(BorderFactory.createTitledBorder(null, "Card", 3, 5, new Font("Tahoma", 0, 11), new Color(255, 255, 255))); this.cardSlot.setBackground(new Color(51, 51, 51)); this.cardSlot.setCursor(new Cursor(0)); this.cardSlot.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent mouseEvent) { ATM.this.cardSlotMouseClicked(mouseEvent); } }); GroupLayout groupLayout4 = new GroupLayout(this.cardSlot); this.cardSlot.setLayout(groupLayout4); groupLayout4.setHorizontalGroup(groupLayout4.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 118, 32767)); groupLayout4.setVerticalGroup(groupLayout4.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 15, 32767)); GroupLayout groupLayout5 = new GroupLayout(this.jPanel4); this.jPanel4.setLayout(groupLayout5); groupLayout5.setHorizontalGroup(groupLayout5.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout5.createSequentialGroup().addContainerGap().addComponent(this.cardSlot, -1, -1, 32767).addContainerGap())); groupLayout5.setVerticalGroup(groupLayout5.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout5.createSequentialGroup().addContainerGap().addComponent(this.cardSlot, -2, -1, -2).addContainerGap(-1, 32767))); this.jPanel4.setBounds(0, 0, 150, 55); this.jLayeredPane1.add((Component)this.jPanel4, JLayeredPane.DEFAULT_LAYER); this.jPanel5.setBackground(new Color(153, 153, 153)); this.jPanel5.setBorder(BorderFactory.createTitledBorder(null, "Reciept", 3, 5, new Font("Tahoma", 0, 11), new Color(255, 255, 255))); this.recieptSlot.setBackground(new Color(51, 51, 51)); GroupLayout groupLayout6 = new GroupLayout(this.recieptSlot); this.recieptSlot.setLayout(groupLayout6); groupLayout6.setHorizontalGroup(groupLayout6.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 158, 32767)); groupLayout6.setVerticalGroup(groupLayout6.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 15, 32767)); GroupLayout groupLayout7 = new GroupLayout(this.jPanel5); this.jPanel5.setLayout(groupLayout7); groupLayout7.setHorizontalGroup(groupLayout7.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, groupLayout7.createSequentialGroup().addContainerGap().addComponent(this.recieptSlot, -1, -1, 32767).addContainerGap())); groupLayout7.setVerticalGroup(groupLayout7.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, groupLayout7.createSequentialGroup().addContainerGap(-1, 32767).addComponent(this.recieptSlot, -2, -1, -2).addGap(96, 96, 96))); this.jPanel5.setBounds(160, 0, 190, 55); this.jLayeredPane1.add((Component)this.jPanel5, JLayeredPane.DEFAULT_LAYER); this.jPanel8.setBackground(new Color(153, 153, 153)); this.jPanel8.setBorder(BorderFactory.createTitledBorder(null, "Cash", 0, 0, new Font("Tahoma", 0, 11), new Color(255, 255, 255))); this.jPanel9.setBackground(new Color(51, 51, 51)); GroupLayout groupLayout8 = new GroupLayout(this.jPanel9); this.jPanel9.setLayout(groupLayout8); groupLayout8.setHorizontalGroup(groupLayout8.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 318, 32767)); groupLayout8.setVerticalGroup(groupLayout8.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 22, 32767)); GroupLayout groupLayout9 = new GroupLayout(this.jPanel8); this.jPanel8.setLayout(groupLayout9); groupLayout9.setHorizontalGroup(groupLayout9.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout9.createSequentialGroup().addContainerGap().addComponent(this.jPanel9, -1, -1, 32767).addContainerGap())); groupLayout9.setVerticalGroup(groupLayout9.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout9.createSequentialGroup().addComponent(this.jPanel9, -2, -1, -2).addGap(0, 11, 32767))); this.jPanel8.setBounds(0, 60, 350, 60); this.jLayeredPane1.add((Component)this.jPanel8, JLayeredPane.DEFAULT_LAYER); GroupLayout groupLayout10 = new GroupLayout(this.getContentPane()); this.getContentPane().setLayout(groupLayout10); groupLayout10.setHorizontalGroup(groupLayout10.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout10.createSequentialGroup().addContainerGap().addGroup(groupLayout10.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout10.createSequentialGroup().addComponent(this.jPanel3, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.jLayeredPane1)).addGroup(groupLayout10.createSequentialGroup().addGroup(groupLayout10.createParallelGroup(GroupLayout.Alignment.LEADING, false).addComponent(this.jPanel1, -1, 504, 32767).addComponent(this.ATMLabel, -1, -1, 32767)).addGap(0, 9, 32767))))); groupLayout10.setVerticalGroup(groupLayout10.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout10.createSequentialGroup().addContainerGap().addComponent(this.ATMLabel, -2, 58, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jPanel1, -2, -1, -2).addGap(18, 18, 18).addGroup(groupLayout10.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(groupLayout10.createSequentialGroup().addComponent(this.jLayeredPane1, -2, 188, -2).addContainerGap()).addGroup(groupLayout10.createSequentialGroup().addComponent(this.jPanel3, -2, -1, -2).addGap(0, 0, 32767))))); this.pack(); } private void initVariables() { this.DEBUG_KEYPAD = false; this.tempEntry = ""; this.screenState = 1; this.updateScreen(); } private void printToScreen(String string) { this.printToScreen(string, false); } private void printToScreen(String string, boolean bl) { if (bl) { string = this.mainConsole.getText() + string; } this.mainConsole.setText(string); } private String getScreenMessage() { return this.mainConsole.getText(); } private static String getFolder(String string) { int n = string.lastIndexOf(File.separatorChar); if (n < 0) { n = string.lastIndexOf("/"); } if (n >= 0) { return string.substring(0, n + 1); } return "./"; } private void cardSlotMouseClicked(MouseEvent mouseEvent) { Object object; // Class<?> class_; ClassLoader classLoader; this.printToScreen("Loading Card"); String string = "." + File.separator + "Card.class"; File file = new File(string); ClassLoader classLoader2 = classLoader = ClassLoader.getSystemClassLoader(); try { object = new URL("file:" + System.getProperty("user.dir") + File.separator + "Card.class"); // class_ = new File(System.getProperty("user.dir")); classLoader2 = URLClassLoader.newInstance(new URL[]{file.toURI().toURL(), class_.toURI().toURL(), object}, classLoader); } catch (MalformedURLException var6_7) { var6_7.printStackTrace(); } object = "Card"; try { // class_ = classLoader2.loadClass((String)object); } catch (ClassNotFoundException var8_9) { this.printToScreen("Card swipe invalid, please try again."); return; } this.printToScreen("Reading card data and verifying ATM"); try { Method method = class_.getMethod("swipe", ATM.class); Data data = (Data)method.invoke(null, this); if (data == null) { this.printToScreen("Machine considered invalid"); } else { this.user = data; this.tempEntry = ""; this.screenState = 2; this.updateScreen(); } } catch (SecurityException var8_11) { this.printToScreen("Security Exception when swiping card."); } catch (NoSuchMethodException var8_12) { this.printToScreen("No Such method exception when swiping card."); } catch (IllegalArgumentException var8_13) { this.printToScreen("Illegal Argument exception when swiping card."); } catch (IllegalAccessException var8_14) { this.printToScreen("Illegal Access exception when swiping card."); } catch (InvocationTargetException var8_15) { this.printToScreen("Invocation Target exception when swiping card."); } } private void updateScreen() { this.tempEntry = ""; switch (this.screenState) { case 1: { this.printToScreen("Please insert your card"); break; } case 2: { this.printToScreen("Welcome, " + this.user.name + "\nPlease enter your pin number.\nPress OK when done\nPress X to Return your Card\nPin: "); break; } case 3: { this.printToScreen("What would you like to do\n1)Check Balance\n2)Withdraw from your account " + this.user.account + "\n3)Return Card"); break; } case 5: { this.printToScreen("Your balance for the account " + this.user.account + "\n" + "$" + this.userBalance + "\n\nPress 1 to Return to Main"); break; } case 6: { this.printToScreen("Select an amount or enter one\n1) $20.00\n2) $40.00\n3) $60.00\n4) $80.00\n5) $100.00\n6) $200.00\n7) Return to Main\n\nEntered Amount: "); break; } case 7: { this.printToScreen("Insufficient funds\n\nPress 1 to Return"); break; } case 8: { this.printToScreen("Debug Mode\nMoney in the Machine: " + this.moneyInMachine + "\n1) Test widthdraw\n2) Return to Main"); } } } private void widthdrawAmount(int n) { if (this.userBalance - n < 0 || this.moneyInMachine - n < 0) { this.screenState = 7; } else { this.userBalance -= n; this.moneyInMachine -= n; this.outputBill(n); this.screenState = 3; } this.updateScreen(); } private void outputBill(int n) { this.cash.setVisible(true); this.cashamount.setText("$" + n + ".00"); } private void ejectCard() { this.user = null; this.screenState = 1; this.updateScreen(); } private void cashMouseClicked(MouseEvent mouseEvent) { this.cash.setVisible(false); } private void pin1MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "1"; this.printToScreen(this.DEBUG_KEYPAD ? "1" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "1"; this.printToScreen("1", true); } } private void pin2MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "2"; this.printToScreen(this.DEBUG_KEYPAD ? "2" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "2"; this.printToScreen("2", true); } } private void pin3MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "3"; this.printToScreen(this.DEBUG_KEYPAD ? "3" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "3"; this.printToScreen("3", true); } } private void pin4MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "4"; this.printToScreen(this.DEBUG_KEYPAD ? "4" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "4"; this.printToScreen("4", true); } } private void pin5MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "5"; this.printToScreen(this.DEBUG_KEYPAD ? "5" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "5"; this.printToScreen("5", true); } } private void pin6MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "6"; this.printToScreen(this.DEBUG_KEYPAD ? "6" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "6"; this.printToScreen("6", true); } } private void pin7MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "7"; this.printToScreen(this.DEBUG_KEYPAD ? "7" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "7"; this.printToScreen("7", true); } } private void pin8MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "8"; this.printToScreen(this.DEBUG_KEYPAD ? "8" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "8"; this.printToScreen("8", true); } } private void pin9MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "9"; this.printToScreen(this.DEBUG_KEYPAD ? "9" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "9"; this.printToScreen("9", true); } } private void pin0MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.tempEntry = this.tempEntry + "0"; this.printToScreen(this.DEBUG_KEYPAD ? "0" : "*", true); } else if (this.screenState == 6) { this.tempEntry = this.tempEntry + "0"; this.printToScreen("0", true); } } private void pinOKMouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { if (!this.tempEntry.equals("")) { try { int n = Integer.valueOf(this.tempEntry); if (n != this.user.pinNumber) { this.updateScreen(); } else { this.screenState = 3; this.updateScreen(); } } catch (Exception var2_3) { this.updateScreen(); } this.tempEntry = ""; } } else if (this.screenState == 6 && !this.tempEntry.equals("")) { int n = Integer.valueOf(this.tempEntry); this.widthdrawAmount(n); } } private void pinCancelMouseClicked(MouseEvent mouseEvent) { if (this.screenState == 2) { this.ejectCard(); } else if (this.screenState == 4 || this.screenState == 6) { this.screenState = 3; this.updateScreen(); } } private void scrn1MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 3) { this.screenState = 5; this.updateScreen(); } else if (this.screenState == 5 || this.screenState == 7) { this.screenState = 3; this.updateScreen(); } else if (this.screenState == 6) { this.widthdrawAmount(20); } else if (this.screenState == 8 && this.moneyInMachine - this.DEBUG_AMOUNT >= 0) { this.outputBill(this.DEBUG_AMOUNT); this.moneyInMachine -= this.DEBUG_AMOUNT; this.updateScreen(); } } private void scrn2MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 3) { this.screenState = 6; this.tempEntry = ""; this.updateScreen(); } else if (this.screenState == 6) { this.widthdrawAmount(40); } else if (this.screenState == 8) { this.screenState = 3; this.tempEntry = ""; this.updateScreen(); } } private void scrn3MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 3) { this.ejectCard(); } else if (this.screenState == 6) { this.widthdrawAmount(60); } } private void scrn4MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 6) { this.widthdrawAmount(80); } } private void scrn5MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 6) { this.widthdrawAmount(100); } } private void scrn6MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 6) { this.widthdrawAmount(200); } } private void scrn7MouseClicked(MouseEvent mouseEvent) { if (this.screenState == 6) { this.screenState = 3; this.updateScreen(); } } private void scrn8MouseClicked(MouseEvent mouseEvent) { } private void showDebug() { this.screenState = 8; this.updateScreen(); } public int applyDecryption(int n) { BigInteger bigInteger = BigInteger.valueOf(n); BigInteger bigInteger2 = BigInteger.valueOf(SECRET_KEY); bigInteger = bigInteger.pow(SECRET_KEY_2); bigInteger = bigInteger.mod(bigInteger2); return bigInteger.intValue(); } public static void main(String[] arrstring) { try { for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) { if (!"Nimbus".equals(lookAndFeelInfo.getName())) continue; UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); break; } } catch (ClassNotFoundException var1_2) { Logger.getLogger(ATM.class.getName()).log(Level.SEVERE, null, var1_2); } catch (InstantiationException var1_3) { Logger.getLogger(ATM.class.getName()).log(Level.SEVERE, null, var1_3); } catch (IllegalAccessException var1_4) { Logger.getLogger(ATM.class.getName()).log(Level.SEVERE, null, var1_4); } catch (UnsupportedLookAndFeelException var1_5) { Logger.getLogger(ATM.class.getName()).log(Level.SEVERE, null, var1_5); } EventQueue.invokeLater(new Runnable(){ @Override public void run() { new ATM().setVisible(true); } }); } public static class Data { public int card; public int account; public String name; public int pinNumber; public Data(int n, int n2, String string, int n3) { this.card = n; this.account = n2; this.name = string; this.pinNumber = n3; } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.