Advertisement
Guest User

działa

a guest
Apr 19th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.43 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 kartoteka.impl.Kartoteka;
  7.  
  8. import java.util.Scanner;
  9. import kartoteka.Osoba.Osoba;
  10.  
  11.  
  12.  
  13.  public class Kartoteka{
  14.      Osoba[] tablica = new Osoba[100];
  15.      int index = 0;
  16.    
  17.  
  18.  public void dodaj( Osoba o){
  19.   tablica[index]=o;
  20.    ++ index;};
  21.     public void usuń(Osoba o){-- index;
  22.     tablica[index]=null;};
  23.     public int rozmiar(){return tablica.length; };
  24.     public  boolean czyZawiera(Osoba o){
  25.         int i=0;
  26.         for(;i<tablica.length;++i)
  27.             return tablica[i]==o;
  28.          return false;
  29.      
  30.        
  31.     };
  32.     public  Osoba pobierz (int index) {
  33.         if(tablica[index]==null){
  34.             System.out.println("ZAPIS O PODANYM NUMERZE NIE ISTNIEJE.ZWRACA 0");
  35.            
  36.            
  37.         }
  38.        
  39.        return tablica[index] ;  
  40.     };
  41.  
  42.     /**
  43.      *
  44.      */
  45.     @Override
  46.  public void finalize (){
  47.      System.out.println("Karol karol");
  48.  }
  49. /**
  50.  *
  51.  * @author Karol
  52.      * @param args
  53.  */
  54.  
  55.    
  56.    
  57.     public static void main(String[] args) {
  58.         Kartoteka kartoteka = new Kartoteka ();
  59.         Osoba o1 = new Osoba("Karol","ROGUCKI");
  60.         System.out.println(" Wybierz opcje 1-5 aby kontynuowac prace z programem : \n"
  61.                 +"1.dodaj osobe do kartoteki \n"
  62.                 +"2.usun osobe z kartoteki \n"
  63.                 +"3.sprawdz  ile osob jest juz wpisanych \n"
  64.                 +"4.sprawdz czy kartoteka zawierajuz dana osobe \n"
  65.                 +"5.pobierz dane osobowe osoby wpisanej w kartotece \n");
  66.         Scanner skaner = new Scanner(System.in)  ;
  67.         int wybor = skaner.nextInt();
  68.         switch(wybor){
  69.             case 1:
  70.                 kartoteka.dodaj(o1);
  71.                
  72.                 break ;
  73.             case 2 :
  74.                 kartoteka.usuń(o1);
  75.                 break ;
  76.             case 3 :
  77.                 kartoteka.rozmiar();
  78.                 break ;
  79.             case 4 :
  80.                 kartoteka.czyZawiera(o1);
  81.                 break ;
  82.             case 5 :
  83.                 kartoteka.pobierz(0);
  84.                 break ;
  85.             default:
  86.                 System.out.println("Podales zla opcje.Probuj dalej");
  87.                 System.exit(0);
  88.                
  89.         }
  90.         System.gc();
  91.         }
  92.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement