Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.ListIterator;
- import java.util.stream.*;
- import java.lang.String;
- public class HumanResources {
- public List<Employee> hr = new ArrayList<>();
- public void init() {
- hr.add(new Employee("Roland", 39495, 60000));
- hr.add(new Employee("Beate", 49595, 30000));
- hr.add(new Employee("Hermann", 94959, 50000));
- };
- public void print1(){
- for (Employee p : hr){
- p.print();
- }
- }
- public void print2(){
- for (int i = 0; i < hr.size(); i++){
- hr.get(i).print();
- }
- }
- //using the ListIterator
- public void print3 () {
- for (ListIterator<Employee> li = hr.listIterator();
- li.hasNext(); )
- li.next().print();
- }
- //using streams technique
- public void print4 () {
- hr.stream().forEach(p -> p.print());
- hr.stream().forEach (Employee :: print);
- }
- public void dispense() {
- print1();
- for (Employee c : hr){
- c.increase_salary(100);
- hr.stream().forEach((p) -> p.increase_salary(100));
- print1();
- }
- }
- public static void main (String [] args){
- HumanResources pa = new HumanResources();
- pa.init();
- pa.dispense();
- pa.toString();
- System.out.println(pa);
- }
- }
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JTextArea;
- public class MyJFrameButton extends JFrame {
- private final JButton schalter = new JButton("Show Employees");
- private final JLabel anzeige = new JLabel(" ");
- private final JLabel anzeige2 = new JLabel(" ");
- public MyJFrameButton (String kopfZeile){
- super(kopfZeile);
- add(schalter, java.awt.BorderLayout.NORTH);
- add(anzeige, java.awt.BorderLayout.CENTER);
- add(anzeige2, java.awt.BorderLayout.SOUTH);
- schalter.addActionListener(ActionEvent -> anzeige.setText("Our company has the following employees"));
- anzeige2.setText(xx);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setSize(500, 200);
- setVisible(true);
- }
- public static void main (String [] args){
- javax.swing.SwingUtilities.invokeLater(
- () -> new MyJFrameButton("Siemens AG"));
- HumanResources xx = new HumanResources();
- xx.init();
- xx.dispense();
- xx.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement