Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package zad8.bank;
  7. import java.util.Scanner;
  8. /**
  9. *
  10. * @author bomba
  11. */
  12. public class Zad8Bank {
  13.  
  14. /**
  15. * @param args the command line arguments
  16. */
  17. public static void main(String[] args) {
  18. // TODO code application logic here
  19. Bank b = new Bank();
  20.  
  21. Klient o1 = new Osoba("Gerard", "Gosk", "215521");
  22. o1.dodajKonto(new Konto("1512"));
  23. o1.getKonta().getFirst().wplac(5000);
  24. o1.dodajKonto(new Konto("2511"));
  25. b.dodajKlienta(o1);
  26.  
  27. Klient o2 = new WaznaOsoba("Jan","Kowalski","214214");
  28. b.dodajKlienta(o2);
  29. o2.dodajKonto(new Konto("1242"));
  30. o2.getKonta().getFirst().wplac(5000000);
  31.  
  32. Klient f1 = new Firma("Szkoła A","21412");
  33. b.dodajKlienta(f1);
  34. f1.dodajKonto(new Konto("12521"));
  35. f1.dodajKonto(new Konto("14521"));
  36. f1.dodajKonto(new Konto("12621"));
  37. f1.getKonta().get(0).wplac(10000);
  38. f1.getKonta().get(2).wplac(2000);
  39. f1.getKonta().get(1).wplac(6000);
  40. f1.getKonta().get(0).wplac(1000);
  41. f1.getKonta().get(1).wplac(18000);
  42.  
  43. Klient f2 = new DuzaFirma("Szkoła B","12331");
  44. f2.dodajKonto(new Konto("21412"));
  45. f2.getKonta().getFirst().wplac(90000000);
  46. b.dodajKlienta(f2);
  47.  
  48. int menu,suma;
  49. boolean stop_menu = false;
  50. Scanner in = new Scanner(System.in);
  51. while(!stop_menu){
  52. System.out.println("Menu: ");
  53. System.out.println("1) Wypisz środki wszystkich firm ");
  54. System.out.println("2) Wypisz środki wszystkich osób");
  55. System.out.println("3) Wypisz środki wszystkich dużych firm i ważnych osób");
  56. System.out.println("4) Wypisz środki wszystkich zwykłych osób");
  57. System.out.println("5) Wyjdz");
  58. menu = in.nextInt();
  59. switch(menu){
  60. case 1:
  61. suma = 0;
  62. for(int i=0; i<b.getKlienci().size(); i++){
  63.  
  64. if(b.getKlienci().get(i)instanceof Firma){
  65. for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
  66. suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
  67. }
  68. }
  69. }
  70. System.out.println("Suma: "+suma);
  71. break;
  72. case 2:
  73. suma = 0;
  74. for(int i=0; i<b.getKlienci().size(); i++){
  75.  
  76. if(b.getKlienci().get(i)instanceof Osoba){
  77. for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
  78. suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
  79. }
  80. }
  81. }
  82. System.out.println("Suma: "+suma);
  83. break;
  84. case 3:
  85. suma = 0;
  86. for(int i=0; i<b.getKlienci().size(); i++){
  87.  
  88. if(b.getKlienci().get(i)instanceof WaznaOsoba || b.getKlienci().get(i)instanceof DuzaFirma ){
  89. for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
  90. suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
  91. }
  92. }
  93. }
  94. System.out.println("Suma: "+suma);
  95. break;
  96. case 4:
  97. suma = 0;
  98. for(int i=0; i<b.getKlienci().size(); i++){
  99.  
  100. if(b.getKlienci().get(i)instanceof Osoba && !(b.getKlienci().get(i)instanceof WaznaOsoba) ){
  101. for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
  102. suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
  103. }
  104. }
  105. }
  106. System.out.println("Suma: "+suma);
  107. break;
  108. case 5:
  109. in.close();
  110. stop_menu = true;
  111. break;
  112. }
  113.  
  114.  
  115. }
  116.  
  117.  
  118. }
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement