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 kartoteka.impl.Kartoteka;
- import java.util.Scanner;
- import kartoteka.Osoba.Osoba;
- public class Kartoteka{
- Osoba[] tablica = new Osoba[100];
- int index = 0;
- public void dodaj( Osoba o){
- tablica[index]=o;
- ++ index;};
- public void usuń(Osoba o){-- index;
- tablica[index]=null;};
- public int rozmiar(){return tablica.length; };
- public boolean czyZawiera(Osoba o){
- int i=0;
- for(;i<tablica.length;++i)
- return tablica[i]==o;
- return false;
- };
- public Osoba pobierz (int index) {
- if(tablica[index]==null){
- System.out.println("ZAPIS O PODANYM NUMERZE NIE ISTNIEJE.ZWRACA 0");
- }
- return tablica[index] ;
- };
- /**
- *
- */
- @Override
- public void finalize (){
- System.out.println("Karol karol");
- }
- /**
- *
- * @author Karol
- * @param args
- */
- public static void main(String[] args) {
- Kartoteka kartoteka = new Kartoteka ();
- Osoba o1 = new Osoba("Karol","ROGUCKI");
- System.out.println(" Wybierz opcje 1-5 aby kontynuowac prace z programem : \n"
- +"1.dodaj osobe do kartoteki \n"
- +"2.usun osobe z kartoteki \n"
- +"3.sprawdz ile osob jest juz wpisanych \n"
- +"4.sprawdz czy kartoteka zawierajuz dana osobe \n"
- +"5.pobierz dane osobowe osoby wpisanej w kartotece \n");
- Scanner skaner = new Scanner(System.in) ;
- int wybor = skaner.nextInt();
- switch(wybor){
- case 1:
- kartoteka.dodaj(o1);
- break ;
- case 2 :
- kartoteka.usuń(o1);
- break ;
- case 3 :
- kartoteka.rozmiar();
- break ;
- case 4 :
- kartoteka.czyZawiera(o1);
- break ;
- case 5 :
- kartoteka.pobierz(0);
- break ;
- default:
- System.out.println("Podales zla opcje.Probuj dalej");
- System.exit(0);
- }
- System.gc();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement