Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package zad8.bank;
- import java.util.Scanner;
- /**
- *
- * @author bomba
- */
- public class Zad8Bank {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Bank b = new Bank();
- Klient o1 = new Osoba("Gerard", "Gosk", "215521");
- o1.dodajKonto(new Konto("1512"));
- o1.getKonta().getFirst().wplac(5000);
- o1.dodajKonto(new Konto("2511"));
- b.dodajKlienta(o1);
- Klient o2 = new WaznaOsoba("Jan","Kowalski","214214");
- b.dodajKlienta(o2);
- o2.dodajKonto(new Konto("1242"));
- o2.getKonta().getFirst().wplac(5000000);
- Klient f1 = new Firma("Szkoła A","21412");
- b.dodajKlienta(f1);
- f1.dodajKonto(new Konto("12521"));
- f1.dodajKonto(new Konto("14521"));
- f1.dodajKonto(new Konto("12621"));
- f1.getKonta().get(0).wplac(10000);
- f1.getKonta().get(2).wplac(2000);
- f1.getKonta().get(1).wplac(6000);
- f1.getKonta().get(0).wplac(1000);
- f1.getKonta().get(1).wplac(18000);
- Klient f2 = new DuzaFirma("Szkoła B","12331");
- f2.dodajKonto(new Konto("21412"));
- f2.getKonta().getFirst().wplac(90000000);
- b.dodajKlienta(f2);
- int menu,suma;
- boolean stop_menu = false;
- Scanner in = new Scanner(System.in);
- while(!stop_menu){
- System.out.println("Menu: ");
- System.out.println("1) Wypisz środki wszystkich firm ");
- System.out.println("2) Wypisz środki wszystkich osób");
- System.out.println("3) Wypisz środki wszystkich dużych firm i ważnych osób");
- System.out.println("4) Wypisz środki wszystkich zwykłych osób");
- System.out.println("5) Wyjdz");
- menu = in.nextInt();
- switch(menu){
- case 1:
- suma = 0;
- for(int i=0; i<b.getKlienci().size(); i++){
- if(b.getKlienci().get(i)instanceof Firma){
- for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
- suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
- }
- }
- }
- System.out.println("Suma: "+suma);
- break;
- case 2:
- suma = 0;
- for(int i=0; i<b.getKlienci().size(); i++){
- if(b.getKlienci().get(i)instanceof Osoba){
- for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
- suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
- }
- }
- }
- System.out.println("Suma: "+suma);
- break;
- case 3:
- suma = 0;
- for(int i=0; i<b.getKlienci().size(); i++){
- if(b.getKlienci().get(i)instanceof WaznaOsoba || b.getKlienci().get(i)instanceof DuzaFirma ){
- for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
- suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
- }
- }
- }
- System.out.println("Suma: "+suma);
- break;
- case 4:
- suma = 0;
- for(int i=0; i<b.getKlienci().size(); i++){
- if(b.getKlienci().get(i)instanceof Osoba && !(b.getKlienci().get(i)instanceof WaznaOsoba) ){
- for(int j=0; j<b.getKlienci().get(i).getKonta().size(); j++){
- suma += b.getKlienci().get(i).getKonta().get(j).getSaldo();
- }
- }
- }
- System.out.println("Suma: "+suma);
- break;
- case 5:
- in.close();
- stop_menu = true;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement