Advertisement
Guest User

Untitled

a guest
May 5th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. package ćw6;
  2.  
  3. import java.util.LinkedList;
  4. import java.util.Random;
  5.  
  6. public class Pracownik
  7. {
  8.     String name;
  9.     String surname;
  10.     int age;
  11.     static LinkedList<String> lista1 = new LinkedList<String>();
  12.     static LinkedList<String> lista2 = new LinkedList<String>();
  13.  
  14.     public Pracownik()
  15.     {
  16.     }
  17.  
  18.     public String getName()
  19.     {
  20.         if (lista1.isEmpty() == false)
  21.             {
  22.                 return lista1.removeLast();
  23.             } else
  24.             {
  25.                 System.out.println("Lista imion jest pusta!\n");
  26.                 return "empty";
  27.             }
  28.     }
  29.  
  30.     public String getSurname()
  31.     {
  32.         if (lista2.isEmpty() == false)
  33.             {
  34.                 return lista2.removeLast();
  35.             } else
  36.             {
  37.                 System.out.println("Lista nazwisk jest pusta!\n");
  38.                 return "empty";
  39.             }
  40.     }
  41.  
  42.     public int getAge()
  43.     {
  44.         Random random = new Random();
  45.         return random.nextInt(22) + 18;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement