Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.32 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.Color;
  3. import java.awt.Container;
  4. import java.awt.FlowLayout;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. public class BankAccountTestGui extends JApplet implements ActionListener {
  8. private JLabel label1, label2;
  9. private JTextField txtName; //txtStatus;
  10. private JTextArea txtEntry;
  11. private JButton createAcButton, listReportButton, deposit, withdraw, balance, logIn, showId;
  12. private final int SIZE = 10;
  13. public void init() {
  14. Container contentPane = getContentPane();
  15. contentPane.setBackground(Color.GRAY);
  16. txtName = new JTextField("Status");
  17. label1 = new JLabel("Hello ");
  18. label2 = new JLabel("out there!");
  19. createAcButton = new JButton("New Account");
  20. createAcButton.addActionListener(this);
  21.  
  22. deposit = new JButton("Deposit");
  23. deposit.addActionListener(this);
  24.  
  25. withdraw = new JButton("Withdraw");
  26. withdraw.addActionListener(this);
  27.  
  28. balance = new JButton("Balance");
  29. balance.addActionListener(this);
  30.  
  31. showId = new JButton("Show Id");
  32. showId.addActionListener(this);
  33.  
  34. logIn = new JButton("Log In");
  35. logIn.addActionListener(this);
  36.  
  37. listReportButton = new JButton("Print Account List");
  38. listReportButton.addActionListener(this);
  39. txtName = new JTextField("Enter Customer Name");
  40. txtEntry = new JTextArea();
  41. contentPane.setLayout(new FlowLayout());
  42. contentPane.add(label1);
  43. contentPane.add(label2);
  44. contentPane.add(txtName);
  45. contentPane.add(txtName);
  46. contentPane.add(createAcButton);
  47. contentPane.add(listReportButton);
  48. contentPane.add(txtEntry);
  49. contentPane.add(deposit);
  50. contentPane.add(withdraw);
  51. contentPane.add(balance);
  52. contentPane.add(logIn);
  53. contentPane.add(showId);
  54. }
  55. public void actionPerformed(ActionEvent e) {
  56. BankAccount test = new BankAccount();
  57. String name;
  58. int account;
  59. double amount;
  60.  
  61. if (e.getActionCommand().equals("New Account"))
  62. {
  63. name = txtEntry.getText();
  64. test.createAccount(name);
  65. label2.setText(txtName.getText());
  66. txtName.setText("New Account Created!");
  67. createAcButton.setVisible(false);
  68. txtEntry.setText("");
  69.  
  70. if (e.getActionCommand().equals("Show Id"))
  71. {
  72. name = txtEntry.getText();
  73. txtEntry.setText(Integer.toString(test.getAccount(name)));
  74. txtName.setText("Showing Account Id");
  75. }
  76. if (e.getActionCommand().equals("Deposit"))
  77. {
  78. account = test.getAccount(name);
  79. amount = Double.parseDouble(txtEntry.getText());
  80. test.deposit(amount);
  81. txtName.setText(Double.toString(test.getBalance()));
  82. }
  83. if (e.getActionCommand().equals("Withdraw"))
  84. {
  85. account = test.getAccount(name);
  86. amount = Double.parseDouble(txtEntry.getText());
  87. test.withdraw(amount);
  88. txtName.setText(Double.toString(test.getBalance()));
  89. }
  90. if (e.getActionCommand().equals("Balance"))
  91. {
  92. txtName.setText(Double.toString(test.getBalance()));
  93. }
  94. }
  95. }
  96. }
  97. public class BankAccount
  98. {
  99. private double newBalance;
  100. private double accountBalance;
  101. private int accountNum;
  102. private int[] accountNumArray = new int[25];
  103. private String[] accountNameArray = new String[25];
  104. private double[] accountBalanceArray = new double[25];
  105. private int currentAccount;
  106. private String name;
  107. private int index=0;
  108. private int indexTemp;
  109. public int createAccount(String name)
  110. {
  111. accountNameArray[index] = name;
  112. accountBalanceArray[index] = 0;
  113.  
  114. accountNum = (int) (100 * Math.random());
  115. for(int i = 0; i < accountNumArray.length; i++)
  116. {
  117. while(accountNum == accountNumArray[i])
  118. {
  119. accountNum = (int) (100 * Math.random());
  120. }
  121. }
  122. accountNumArray[index] = accountNum;
  123.  
  124. return accountNum;
  125. }
  126.  
  127. public void setName(String newName , int account)
  128. {
  129. for ( int i = 0; i < accountNumArray.length; i++)
  130. {
  131. if(account == accountNumArray[i])
  132. {
  133. accountNameArray[i] = "newName";
  134. }
  135. }
  136.  
  137. }
  138. public String getName(int account)
  139. {
  140. for(int i = 0; i <accountNameArray.length; i ++)
  141. {
  142. if(account == accountNumArray[i])
  143. {
  144. indexTemp=i;
  145. }
  146. }
  147. name = accountNameArray[indexTemp];
  148. return name;
  149. }
  150. public int getAccount(String name)
  151. {
  152. for(int i = 0; i <accountNameArray.length; i ++)
  153. {
  154. if(name == accountNameArray[i])
  155. {
  156. indexTemp=i;
  157. }
  158. }
  159. accountNum = accountNumArray[indexTemp];
  160. currentAccount = indexTemp;
  161. return accountNum;
  162. }
  163. public double deposit(double deposit)
  164. {
  165. accountBalanceArray[currentAccount] = accountBalanceArray[currentAccount] + deposit;
  166. return accountBalance;
  167. }
  168. public double getBalance()
  169. {
  170. accountBalance = accountBalanceArray[currentAccount];
  171. return accountBalance;
  172. }
  173. public double withdraw(double withdraw)
  174. {
  175. if(accountBalanceArray[currentAccount] - withdraw < 0)
  176. {
  177. newBalance = -1;
  178. }
  179. else
  180. {
  181. accountBalanceArray[currentAccount] = accountBalanceArray[currentAccount] - withdraw;
  182. }
  183. return newBalance;
  184.  
  185. }
  186. }
  187. import java.awt.BorderLayout;
  188. import java.awt.EventQueue;
  189. import java.awt.event.ActionEvent;
  190. import java.awt.event.ActionListener;
  191. import javax.swing.JFrame;
  192. import javax.swing.JPanel;
  193. import javax.swing.border.EmptyBorder;
  194. import javax.swing.JTextField;
  195. import javax.swing.JTextPane;
  196. import javax.swing.JTextArea;
  197. import javax.swing.JFormattedTextField;
  198. import javax.swing.JButton;
  199. import java.awt.event.MouseAdapter;
  200. import java.awt.event.MouseEvent;
  201. import javax.swing.JLabel;
  202. import javax.swing.SwingConstants;
  203. import java.awt.Font;
  204. import java.awt.Color;
  205. import java.awt.event.ContainerAdapter;
  206. import java.awt.event.ContainerEvent;
  207. import javax.swing.JLayeredPane;
  208. import javax.swing.JList;
  209. public class LogInScreen extends JFrame implements ActionListener {
  210. private JPanel contentPane;
  211. private static JPanel panel;
  212.  
  213.  
  214. Workers theWorkers = new Workers();
  215. private JTextField textField;
  216. private JTextField textField_1;
  217. private JLabel lblUserName;
  218. private JLabel lblPassword;
  219. private JTextField textField_2;
  220. private JTextField textField_3;
  221.  
  222. /**
  223. * Launch the application.
  224. */
  225. public static void main(String[] args) {
  226.  
  227. EventQueue.invokeLater(new Runnable() {
  228. public void run() {
  229. try {
  230. LogInScreen frame = new LogInScreen();
  231. frame.setVisible(true);
  232.  
  233. } catch (Exception e) {
  234. e.printStackTrace();
  235. }
  236. }
  237. });
  238. }
  239. /**
  240. * Create the frame.
  241. */
  242. public LogInScreen() {
  243.  
  244.  
  245.  
  246.  
  247.  
  248. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  249. setBounds(100, 100, 939, 739);
  250.  
  251.  
  252.  
  253. contentPane = new JPanel();
  254. contentPane.setBackground(new Color(153, 204, 102));
  255. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  256. setContentPane(contentPane);
  257. contentPane.setLayout(null);
  258.  
  259. JPanel LogIn = new JPanel();
  260. LogIn.setBackground(new Color(102, 153, 102));
  261. LogIn.setBounds(0, 0, 923, 701);
  262. contentPane.add(LogIn);
  263. LogIn.setLayout(null);
  264.  
  265. textField = new JTextField();
  266. textField.setBounds(102, 11, 135, 20);
  267. LogIn.add(textField);
  268. textField.setColumns(10);
  269.  
  270. textField_1 = new JTextField();
  271. textField_1.setBounds(336, 11, 135, 20);
  272. LogIn.add(textField_1);
  273. textField_1.setColumns(10);
  274.  
  275. JButton btnNewButton = new JButton("Log In");
  276. btnNewButton.addActionListener(new ActionListener() {
  277. public void actionPerformed(ActionEvent arg0) {
  278. }
  279. });
  280. btnNewButton.setBounds(495, 10, 109, 23);
  281. LogIn.add(btnNewButton);
  282.  
  283. lblUserName = new JLabel("User Name");
  284. lblUserName.setBounds(35, 14, 85, 14);
  285. LogIn.add(lblUserName);
  286.  
  287. lblPassword = new JLabel("Password");
  288. lblPassword.setBounds(260, 14, 46, 14);
  289. LogIn.add(lblPassword);
  290.  
  291. JButton btnNewButton_1 = new JButton("Remove");
  292. btnNewButton_1.addActionListener(new ActionListener() {
  293. public void actionPerformed(ActionEvent e) {
  294. }
  295. });
  296. btnNewButton_1.setBounds(580, 60, 93, 56);
  297. LogIn.add(btnNewButton_1);
  298.  
  299. JButton button = new JButton("Add Quantity");
  300. button.addActionListener(new ActionListener() {
  301. public void actionPerformed(ActionEvent e) {
  302. }
  303. });
  304. button.setBounds(683, 60, 108, 56);
  305. LogIn.add(button);
  306.  
  307. JButton button_1 = new JButton("Less Quantity");
  308. button_1.setBounds(801, 60, 112, 56);
  309. LogIn.add(button_1);
  310.  
  311. JButton btnNewButton_2 = new JButton("Check Out");
  312. btnNewButton_2.addActionListener(new ActionListener() {
  313. public void actionPerformed(ActionEvent e) {
  314. }
  315. });
  316. btnNewButton_2.setBounds(614, 620, 287, 37);
  317. LogIn.add(btnNewButton_2);
  318.  
  319. JList list = new JList();
  320. list.setBounds(614, 127, 287, 413);
  321. LogIn.add(list);
  322.  
  323. JLabel lblTotal = new JLabel("Total");
  324. lblTotal.setFont(new Font("Tahoma", Font.BOLD, 16));
  325. lblTotal.setHorizontalAlignment(SwingConstants.CENTER);
  326. lblTotal.setBounds(503, 579, 101, 23);
  327. LogIn.add(lblTotal);
  328.  
  329. JList list_1 = new JList();
  330. list_1.setBounds(47, 478, 275, 146);
  331. LogIn.add(list_1);
  332.  
  333. textField_2 = new JTextField();
  334. textField_2.setBounds(47, 447, 275, 20);
  335. LogIn.add(textField_2);
  336. textField_2.setColumns(10);
  337.  
  338. JButton btnNewButton_3 = new JButton("Select");
  339. btnNewButton_3.addActionListener(new ActionListener() {
  340. public void actionPerformed(ActionEvent e) {
  341. }
  342. });
  343. btnNewButton_3.setBounds(47, 634, 85, 34);
  344. LogIn.add(btnNewButton_3);
  345.  
  346. JButton button_2 = new JButton("Add");
  347. button_2.addActionListener(new ActionListener() {
  348. public void actionPerformed(ActionEvent e) {
  349. }
  350. });
  351. button_2.setBounds(142, 635, 85, 34);
  352. LogIn.add(button_2);
  353.  
  354. JButton button_3 = new JButton("Remove");
  355. button_3.addActionListener(new ActionListener() {
  356. public void actionPerformed(ActionEvent e) {
  357. }
  358. });
  359. button_3.setBounds(237, 634, 85, 34);
  360. LogIn.add(button_3);
  361.  
  362. JLabel lblProductListSearch = new JLabel("Product List Search");
  363. lblProductListSearch.setFont(new Font("Tahoma", Font.BOLD, 16));
  364. lblProductListSearch.setHorizontalAlignment(SwingConstants.CENTER);
  365. lblProductListSearch.setBounds(47, 399, 275, 37);
  366. LogIn.add(lblProductListSearch);
  367.  
  368. JTextArea textArea = new JTextArea();
  369. textArea.setBounds(615, 565, 287, 37);
  370. LogIn.add(textArea);
  371.  
  372. JButton btnNewButton_4 = new JButton("Iphone 5");
  373. btnNewButton_4.addActionListener(new ActionListener() {
  374. public void actionPerformed(ActionEvent e) {
  375. }
  376. });
  377. btnNewButton_4.setBounds(19, 103, 125, 80);
  378. LogIn.add(btnNewButton_4);
  379.  
  380. JButton button_4 = new JButton("Iphone 5s");
  381. button_4.addActionListener(new ActionListener() {
  382. public void actionPerformed(ActionEvent e) {
  383. }
  384. });
  385. button_4.setBounds(154, 103, 131, 80);
  386. LogIn.add(button_4);
  387.  
  388. JButton button_5 = new JButton("Galaxy S4");
  389. button_5.addActionListener(new ActionListener() {
  390. public void actionPerformed(ActionEvent e) {
  391. }
  392. });
  393. button_5.setBounds(295, 103, 125, 80);
  394. LogIn.add(button_5);
  395.  
  396. JButton button_6 = new JButton("Galaxy S3");
  397. button_6.setBounds(295, 194, 125, 80);
  398. LogIn.add(button_6);
  399.  
  400. JButton button_7 = new JButton("Nokia Lumia 900");
  401. button_7.addActionListener(new ActionListener() {
  402. public void actionPerformed(ActionEvent e) {
  403. }
  404. });
  405. button_7.setBounds(154, 194, 131, 80);
  406. LogIn.add(button_7);
  407.  
  408. JButton button_8 = new JButton("HTC One");
  409. button_8.addActionListener(new ActionListener() {
  410. public void actionPerformed(ActionEvent e) {
  411. }
  412. });
  413. button_8.setBounds(19, 194, 125, 80);
  414. LogIn.add(button_8);
  415.  
  416. JButton button_9 = new JButton("HTC Droid DNA");
  417. button_9.setBounds(19, 285, 125, 80);
  418. LogIn.add(button_9);
  419.  
  420. JButton button_10 = new JButton("Google Nexus 4");
  421. button_10.setBounds(154, 285, 131, 80);
  422. LogIn.add(button_10);
  423.  
  424. JButton button_11 = new JButton("Google Nexus 5");
  425. button_11.setBounds(295, 285, 125, 80);
  426. LogIn.add(button_11);
  427.  
  428. JLabel lblPopularItems = new JLabel("Popular Items");
  429. lblPopularItems.setFont(new Font("Tahoma", Font.BOLD, 16));
  430. lblPopularItems.setHorizontalAlignment(SwingConstants.CENTER);
  431. lblPopularItems.setBounds(19, 60, 401, 32);
  432. LogIn.add(lblPopularItems);
  433.  
  434. JLabel lblUserNotLogged = new JLabel("User Not Logged in");
  435. lblUserNotLogged.setBounds(626, 14, 147, 14);
  436. LogIn.add(lblUserNotLogged);
  437.  
  438. textField_3 = new JTextField();
  439. textField_3.setBounds(379, 447, 153, 20);
  440. LogIn.add(textField_3);
  441. textField_3.setColumns(10);
  442.  
  443. JButton btnEnterCustomer = new JButton("Enter Customer");
  444. btnEnterCustomer.setBounds(382, 488, 150, 23);
  445. LogIn.add(btnEnterCustomer);
  446.  
  447. JLabel lblCustomerName = new JLabel("Customer Name");
  448. lblCustomerName.setFont(new Font("Tahoma", Font.BOLD, 16));
  449. lblCustomerName.setHorizontalAlignment(SwingConstants.CENTER);
  450. lblCustomerName.setBounds(379, 416, 153, 20);
  451. LogIn.add(lblCustomerName);
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458. }
  459. public void actionPerformed(ActionEvent arg0) {
  460.  
  461. theWorkers.addWorker("Bob", "password");
  462. theWorkers.addWorker("Chirill", "pw");
  463.  
  464. UserName.getText();
  465. Password.getText();
  466. if(theWorkers.validWorker(UserName.getText(), Password.getText()))
  467. {
  468. System.out.println("log in works");
  469. contentPane.add(CheckOut);
  470. }
  471. else
  472. {
  473. System.out.println("fail");
  474. }
  475.  
  476. }
  477. }
  478. import java.awt.BorderLayout;
  479. import java.awt.EventQueue;
  480. import java.awt.event.ActionEvent;
  481. import java.awt.event.ActionListener;
  482. import javax.swing.JFrame;
  483. import javax.swing.JPanel;
  484. import javax.swing.border.EmptyBorder;
  485. import javax.swing.JTextField;
  486. import javax.swing.JTextPane;
  487. import javax.swing.JTextArea;
  488. import javax.swing.JFormattedTextField;
  489. import javax.swing.JButton;
  490. import java.awt.event.MouseAdapter;
  491. import java.awt.event.MouseEvent;
  492. import javax.swing.JLabel;
  493. import javax.swing.SwingConstants;
  494. import java.awt.Font;
  495. import java.awt.Color;
  496. import java.awt.event.ContainerAdapter;
  497. import java.awt.event.ContainerEvent;
  498. import javax.swing.JLayeredPane;
  499. import javax.swing.JList;
  500. public class LogInScreen extends JFrame implements ActionListener {
  501. private JPanel contentPane;
  502. private static JPanel panel;
  503.  
  504.  
  505. Workers theWorkers = new Workers();
  506. private JTextField textField;
  507. private JTextField textField_1;
  508. private JLabel lblUserName;
  509. private JLabel lblPassword;
  510. private JTextField textField_2;
  511. private JTextField textField_3;
  512.  
  513. /**
  514. * Launch the application.
  515. */
  516. public static void main(String[] args) {
  517.  
  518. EventQueue.invokeLater(new Runnable() {
  519. public void run() {
  520. try {
  521. LogInScreen frame = new LogInScreen();
  522. frame.setVisible(true);
  523.  
  524. } catch (Exception e) {
  525. e.printStackTrace();
  526. }
  527. }
  528. });
  529. }
  530. /**
  531. * Create the frame.
  532. */
  533. public LogInScreen() {
  534.  
  535.  
  536.  
  537.  
  538.  
  539. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  540. setBounds(100, 100, 939, 739);
  541.  
  542.  
  543.  
  544. contentPane = new JPanel();
  545. contentPane.setBackground(new Color(153, 204, 102));
  546. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  547. setContentPane(contentPane);
  548. contentPane.setLayout(null);
  549.  
  550. JPanel LogIn = new JPanel();
  551. LogIn.setBackground(new Color(102, 153, 102));
  552. LogIn.setBounds(0, 0, 923, 701);
  553. contentPane.add(LogIn);
  554. LogIn.setLayout(null);
  555.  
  556. textField = new JTextField();
  557. textField.setBounds(102, 11, 135, 20);
  558. LogIn.add(textField);
  559. textField.setColumns(10);
  560.  
  561. textField_1 = new JTextField();
  562. textField_1.setBounds(336, 11, 135, 20);
  563. LogIn.add(textField_1);
  564. textField_1.setColumns(10);
  565.  
  566. JButton btnNewButton = new JButton("Log In");
  567. btnNewButton.addActionListener(new ActionListener() {
  568. public void actionPerformed(ActionEvent arg0) {
  569. }
  570. });
  571. btnNewButton.setBounds(495, 10, 109, 23);
  572. LogIn.add(btnNewButton);
  573.  
  574. lblUserName = new JLabel("User Name");
  575. lblUserName.setBounds(35, 14, 85, 14);
  576. LogIn.add(lblUserName);
  577.  
  578. lblPassword = new JLabel("Password");
  579. lblPassword.setBounds(260, 14, 46, 14);
  580. LogIn.add(lblPassword);
  581.  
  582. JButton btnNewButton_1 = new JButton("Remove");
  583. btnNewButton_1.addActionListener(new ActionListener() {
  584. public void actionPerformed(ActionEvent e) {
  585. }
  586. });
  587. btnNewButton_1.setBounds(580, 60, 93, 56);
  588. LogIn.add(btnNewButton_1);
  589.  
  590. JButton button = new JButton("Add Quantity");
  591. button.addActionListener(new ActionListener() {
  592. public void actionPerformed(ActionEvent e) {
  593. }
  594. });
  595. button.setBounds(683, 60, 108, 56);
  596. LogIn.add(button);
  597.  
  598. JButton button_1 = new JButton("Less Quantity");
  599. button_1.setBounds(801, 60, 112, 56);
  600. LogIn.add(button_1);
  601.  
  602. JButton btnNewButton_2 = new JButton("Check Out");
  603. btnNewButton_2.addActionListener(new ActionListener() {
  604. public void actionPerformed(ActionEvent e) {
  605. }
  606. });
  607. btnNewButton_2.setBounds(614, 620, 287, 37);
  608. LogIn.add(btnNewButton_2);
  609.  
  610. JList list = new JList();
  611. list.setBounds(614, 127, 287, 413);
  612. LogIn.add(list);
  613.  
  614. JLabel lblTotal = new JLabel("Total");
  615. lblTotal.setFont(new Font("Tahoma", Font.BOLD, 16));
  616. lblTotal.setHorizontalAlignment(SwingConstants.CENTER);
  617. lblTotal.setBounds(503, 579, 101, 23);
  618. LogIn.add(lblTotal);
  619.  
  620. JList list_1 = new JList();
  621. list_1.setBounds(47, 478, 275, 146);
  622. LogIn.add(list_1);
  623.  
  624. textField_2 = new JTextField();
  625. textField_2.setBounds(47, 447, 275, 20);
  626. LogIn.add(textField_2);
  627. textField_2.setColumns(10);
  628.  
  629. JButton btnNewButton_3 = new JButton("Select");
  630. btnNewButton_3.addActionListener(new ActionListener() {
  631. public void actionPerformed(ActionEvent e) {
  632. }
  633. });
  634. btnNewButton_3.setBounds(47, 634, 85, 34);
  635. LogIn.add(btnNewButton_3);
  636.  
  637. JButton button_2 = new JButton("Add");
  638. button_2.addActionListener(new ActionListener() {
  639. public void actionPerformed(ActionEvent e) {
  640. }
  641. });
  642. button_2.setBounds(142, 635, 85, 34);
  643. LogIn.add(button_2);
  644.  
  645. JButton button_3 = new JButton("Remove");
  646. button_3.addActionListener(new ActionListener() {
  647. public void actionPerformed(ActionEvent e) {
  648. }
  649. });
  650. button_3.setBounds(237, 634, 85, 34);
  651. LogIn.add(button_3);
  652.  
  653. JLabel lblProductListSearch = new JLabel("Product List Search");
  654. lblProductListSearch.setFont(new Font("Tahoma", Font.BOLD, 16));
  655. lblProductListSearch.setHorizontalAlignment(SwingConstants.CENTER);
  656. lblProductListSearch.setBounds(47, 399, 275, 37);
  657. LogIn.add(lblProductListSearch);
  658.  
  659. JTextArea textArea = new JTextArea();
  660. textArea.setBounds(615, 565, 287, 37);
  661. LogIn.add(textArea);
  662.  
  663. JButton btnNewButton_4 = new JButton("Iphone 5");
  664. btnNewButton_4.addActionListener(new ActionListener() {
  665. public void actionPerformed(ActionEvent e) {
  666. }
  667. });
  668. btnNewButton_4.setBounds(19, 103, 125, 80);
  669. LogIn.add(btnNewButton_4);
  670.  
  671. JButton button_4 = new JButton("Iphone 5s");
  672. button_4.addActionListener(new ActionListener() {
  673. public void actionPerformed(ActionEvent e) {
  674. }
  675. });
  676. button_4.setBounds(154, 103, 131, 80);
  677. LogIn.add(button_4);
  678.  
  679. JButton button_5 = new JButton("Galaxy S4");
  680. button_5.addActionListener(new ActionListener() {
  681. public void actionPerformed(ActionEvent e) {
  682. }
  683. });
  684. button_5.setBounds(295, 103, 125, 80);
  685. LogIn.add(button_5);
  686.  
  687. JButton button_6 = new JButton("Galaxy S3");
  688. button_6.setBounds(295, 194, 125, 80);
  689. LogIn.add(button_6);
  690.  
  691. JButton button_7 = new JButton("Nokia Lumia 900");
  692. button_7.addActionListener(new ActionListener() {
  693. public void actionPerformed(ActionEvent e) {
  694. }
  695. });
  696. button_7.setBounds(154, 194, 131, 80);
  697. LogIn.add(button_7);
  698.  
  699. JButton button_8 = new JButton("HTC One");
  700. button_8.addActionListener(new ActionListener() {
  701. public void actionPerformed(ActionEvent e) {
  702. }
  703. });
  704. button_8.setBounds(19, 194, 125, 80);
  705. LogIn.add(button_8);
  706.  
  707. JButton button_9 = new JButton("HTC Droid DNA");
  708. button_9.setBounds(19, 285, 125, 80);
  709. LogIn.add(button_9);
  710.  
  711. JButton button_10 = new JButton("Google Nexus 4");
  712. button_10.setBounds(154, 285, 131, 80);
  713. LogIn.add(button_10);
  714.  
  715. JButton button_11 = new JButton("Google Nexus 5");
  716. button_11.setBounds(295, 285, 125, 80);
  717. LogIn.add(button_11);
  718.  
  719. JLabel lblPopularItems = new JLabel("Popular Items");
  720. lblPopularItems.setFont(new Font("Tahoma", Font.BOLD, 16));
  721. lblPopularItems.setHorizontalAlignment(SwingConstants.CENTER);
  722. lblPopularItems.setBounds(19, 60, 401, 32);
  723. LogIn.add(lblPopularItems);
  724.  
  725. JLabel lblUserNotLogged = new JLabel("User Not Logged in");
  726. lblUserNotLogged.setBounds(626, 14, 147, 14);
  727. LogIn.add(lblUserNotLogged);
  728.  
  729. textField_3 = new JTextField();
  730. textField_3.setBounds(379, 447, 153, 20);
  731. LogIn.add(textField_3);
  732. textField_3.setColumns(10);
  733.  
  734. JButton btnEnterCustomer = new JButton("Enter Customer");
  735. btnEnterCustomer.setBounds(382, 488, 150, 23);
  736. LogIn.add(btnEnterCustomer);
  737.  
  738. JLabel lblCustomerName = new JLabel("Customer Name");
  739. lblCustomerName.setFont(new Font("Tahoma", Font.BOLD, 16));
  740. lblCustomerName.setHorizontalAlignment(SwingConstants.CENTER);
  741. lblCustomerName.setBounds(379, 416, 153, 20);
  742. LogIn.add(lblCustomerName);
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749. }
  750. public void actionPerformed(ActionEvent arg0) {
  751.  
  752. theWorkers.addWorker("Bob", "password");
  753. theWorkers.addWorker("Chirill", "pw");
  754.  
  755. UserName.getText();
  756. Password.getText();
  757. if(theWorkers.validWorker(UserName.getText(), Password.getText()))
  758. {
  759. System.out.println("log in works");
  760. contentPane.add(CheckOut);
  761. }
  762. else
  763. {
  764. System.out.println("fail");
  765. }
  766.  
  767. }
  768. }
  769. public class BankAccountTest {
  770.  
  771. public static void main(String[] args)
  772. {
  773. BankAccount mike = new BankAccount();
  774. System.out.println(mike.createAccount());
  775. mike.setName("mike");
  776. mike.deposit(100);
  777. System.out.println(mike.getBalance());
  778. System.out.println(mike.getAccount());
  779.  
  780. }
  781. }
  782. public class BankAccount
  783. {
  784. private double newBalance;
  785. private int accountNum;
  786. private int[] accountNumArray;
  787. private String accountNameArray;
  788. private double balance;
  789. private String name;
  790.  
  791.  
  792. public int createAccount()
  793. {
  794. name = "";
  795. balance = 0;
  796. accountNum = (int) (100*Math.random());
  797. return accountNum;
  798. }
  799. public void setName(String newName)
  800. {
  801. name = "newName";
  802. }
  803. public String getName(int account)
  804. {
  805. return name;
  806. }
  807. public int getAccount()
  808. {
  809. return accountNum;
  810. }
  811.  
  812. public double deposit(double deposit)
  813. {
  814. balance = balance+deposit;
  815. return newBalance;
  816. }
  817. public double getBalance()
  818. {
  819. return balance;
  820. }
  821.  
  822. public double withdraw(double withdraw)
  823. {
  824. balance = balance - withdraw;
  825. return newBalance;
  826. }
  827.  
  828.  
  829.  
  830. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement