Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.util.*;
- /**
- *
- * @author lazar
- */
- public class kolll {
- /**
- * @param args the command line arguments
- */
- String ime;
- String prezime;
- public static void main(String[] args) {
- // TODO code application logic here
- imenik i=new imenik();
- i.dodaj ("Petar", "Kralj");
- i.dodaj("Marko", "Markovic");
- i.prikazi();
- i.pretraga("Lazar", "Stojnic");
- }
- }
- class imenik {
- private List <kolll>is;
- public imenik(){
- is=new ArrayList();
- }
- public void dodaj(String ime,String pre){
- kolll k=new kolll();
- k.ime=ime;
- k.prezime=pre;
- is.add(k);
- }
- public void prikazi (){
- int i=0;
- while (i<this. is.size ()) {
- System.out.println("Ime"+is.get(i).ime+"prezime"+is.get(i).prezime); i++;
- }
- }
- public boolean pretraga (String ime, String pre){
- boolean rezultat = false; for (int i=0; i<this. is .size () ; i++) {
- if(this.is.get(i).ime.equals(ime)){
- System.out.println("Trazeno ime je"+this.is.get(i).ime+"prezime");
- rezultat = true; break;
- }
- }if(rezultat==false){
- System.out.println("Novi kontakt"+ime+pre);
- }
- return rezultat; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement