Advertisement
TsetsoP

employee

Oct 28th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class Employee extends Clothes { //За да има достъп до clothesStorage
  5. static Scanner scan = new Scanner (System.in);
  6.  
  7. private static double ePrice;
  8. private String name, family, egn;
  9. private static ArrayList<Employee> emps = new ArrayList<>();
  10.  
  11. static {
  12. emps.add(new Employee("Ivan", "Ivanov", "9800000000"));
  13. emps.add(new Employee("Asen", "Asenov", "8900000000"));
  14. emps.add(new Employee("Georgi", "Georgiev", "7800000000"));
  15. }
  16.  
  17. public Employee() {
  18.  
  19. }
  20.  
  21. public Employee(String name, String family, String egn) {
  22. this.name = name;
  23. this.family = family;
  24. this.egn = egn;
  25. }
  26.  
  27. public static double getePrice() {
  28. return ePrice;
  29. }
  30. public static void setePrice(double ePrice) {
  31. Employee.ePrice = ePrice;
  32. }
  33. public String getName() {return name;}
  34. public void setName(String name) {this.name = name;}
  35. public String getFamily() {return family;}
  36. public void setFamily(String family) {this.family = family;}
  37. public String getEgn() {return egn;}
  38. public void setEgn(String egn) {this.egn = egn;}
  39.  
  40. public static void getEmployee(String enteredName, String enteredFamily, String enteredEgn) {
  41. boolean bEmployee = true;
  42. for (Employee emp : emps) {
  43. if (emp.name.equalsIgnoreCase(enteredName) && emp.family.equalsIgnoreCase(enteredFamily) && emp.egn.contentEquals(enteredEgn)) {
  44. System.out.println("Влязохте в системата като служител.");
  45. bEmployee = false;
  46. employeeSetPrice(ePrice);
  47. }
  48.  
  49. }
  50. if (bEmployee) {
  51. System.out.println("Няма такъв потребител или сте въвели грешни данни.");
  52. }
  53. }
  54.  
  55. public static void employeeSetPrice(double ePrise) {
  56. for (Clothes cl : clothesStorage) {
  57. cl.getAllInfo();
  58. System.out.println("Задайте нова цена или въведете същата.");
  59. double newPrice = scan.nextDouble();
  60. if (newPrice == cl.getClothePrice()) {
  61. System.out.println("Не променихте цената.");
  62. cl.getAllInfo();
  63. }else if (newPrice != cl.getClothePrice() && newPrice > 0) {
  64. cl.setClothePrice(newPrice);
  65. System.out.println("Променихте цената на продукта. \n Новите данни на продукта: ");
  66. cl.getAllInfo();
  67. }else{
  68. System.out.println("Невалидна сума. ");
  69. cl.getAllInfo();
  70. }
  71. }
  72. }
  73.  
  74.  
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement