Advertisement
Guest User

Untitled

a guest
Mar 17th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.ListIterator;
  4. import java.util.stream.*;
  5. import java.lang.String;
  6.  
  7.  
  8.  
  9. public class HumanResources {
  10.    
  11.     public  List<Employee> hr = new ArrayList<>();
  12.    
  13.    
  14.     public void init()  {
  15.         hr.add(new Employee("Roland", 39495, 60000));
  16.         hr.add(new Employee("Beate", 49595, 30000));
  17.         hr.add(new Employee("Hermann", 94959, 50000));
  18.     };
  19.    
  20.     public void print1(){
  21.         for (Employee p : hr){
  22.             p.print();
  23.         }
  24.     }
  25.    
  26.    
  27.     public void print2(){
  28.         for (int i = 0; i < hr.size(); i++){
  29.             hr.get(i).print();
  30.         }
  31.     }
  32.    
  33.     //using the ListIterator
  34.     public void print3 () {
  35.         for (ListIterator<Employee> li = hr.listIterator();            
  36.                                        li.hasNext();    )
  37.             li.next().print();
  38.     }
  39.    
  40.     //using streams technique
  41.     public void print4 () {
  42.         hr.stream().forEach(p -> p.print());
  43.         hr.stream().forEach (Employee :: print);
  44.        
  45.     }
  46.    
  47.    
  48.     public void dispense() {
  49.         print1();
  50.         for (Employee c : hr){
  51.             c.increase_salary(100);
  52.             hr.stream().forEach((p) -> p.increase_salary(100));
  53.             print1();
  54.            
  55.         }
  56.     }
  57.    
  58.  
  59.    
  60.  
  61.  
  62.    
  63.    
  64.     public static void main (String [] args){
  65.         HumanResources pa = new HumanResources();
  66.         pa.init();
  67.         pa.dispense();
  68.         pa.toString();
  69.    
  70.         System.out.println(pa);
  71.     }
  72.        
  73.  
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. import javax.swing.JButton;
  84. import javax.swing.JFrame;
  85. import javax.swing.JLabel;
  86. import javax.swing.JTextArea;
  87.  
  88.  
  89.  
  90.  
  91.  
  92. public class MyJFrameButton extends JFrame {
  93.    
  94.     private final JButton schalter = new JButton("Show Employees");
  95.     private final JLabel anzeige = new JLabel(" ");
  96.     private final JLabel anzeige2 = new JLabel(" ");
  97.  
  98.  
  99.    
  100.    
  101. public MyJFrameButton (String kopfZeile){
  102.     super(kopfZeile);
  103.     add(schalter, java.awt.BorderLayout.NORTH);
  104.     add(anzeige, java.awt.BorderLayout.CENTER);
  105.     add(anzeige2, java.awt.BorderLayout.SOUTH);
  106.     schalter.addActionListener(ActionEvent -> anzeige.setText("Our company has the following employees"));
  107.     anzeige2.setText(xx);
  108.     setDefaultCloseOperation(EXIT_ON_CLOSE);
  109.     setSize(500, 200);
  110.     setVisible(true);
  111.    
  112.  
  113.    
  114.    
  115. }
  116.  
  117.  
  118.  
  119.  
  120.  
  121. public static void main (String [] args){
  122.     javax.swing.SwingUtilities.invokeLater(
  123.             () -> new MyJFrameButton("Siemens AG"));
  124.    
  125.     HumanResources xx = new HumanResources();
  126.     xx.init();
  127.     xx.dispense();
  128.     xx.toString();
  129.    
  130.    
  131. }
  132.    
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement