Advertisement
TsetsoP

EMPLOYEEEEE

Nov 11th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.44 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class Employee extends Clothes {
  4.  
  5. private static double ePrice;
  6. private String name, family, egn, email, password, username;
  7. protected static ArrayList<Employee> emps = new ArrayList<>();
  8.  
  9. static {
  10. emps.add(new Employee("Ivan", "Ivanov", "9800000000", "[email protected]", "1234i", "ii"));
  11. emps.add(new Employee("Asen", "Asenov", "8900000000", "[email protected]", "1234a", "aa"));
  12. emps.add(new Employee("Georgi", "Georgiev", "7800000000", "[email protected]", "1234g", "gg"));
  13. }
  14.  
  15. public Employee() {
  16.  
  17. }
  18.  
  19. public Employee(String name, String family, String egn, String email, String password, String username) {
  20. this.name = name;
  21. this.family = family;
  22. this.egn = egn;
  23. this.email = email;
  24. this.password = password;
  25. this.username = username;
  26. }
  27.  
  28. public double getePrice() {
  29. return ePrice;
  30. }
  31.  
  32. public void setePrice(double ePrice) {
  33. Employee.ePrice = ePrice;
  34. }
  35.  
  36. public String getName() {
  37. return name;
  38. }
  39.  
  40. public void setName(String name) {
  41. this.name = name;
  42. }
  43.  
  44. public String getFamily() {
  45. return family;
  46. }
  47.  
  48. public void setFamily(String family) {
  49. this.family = family;
  50. }
  51.  
  52. public String getEgn() {
  53. return egn;
  54. }
  55.  
  56. public void setEgn(String egn) {
  57. this.egn = egn;
  58. }
  59.  
  60. public String getEmail() {
  61. return email;
  62. }
  63.  
  64. public void setEmail(String email) {
  65. this.email = email;
  66. }
  67.  
  68. public String getPassword() {
  69. return password;
  70. }
  71.  
  72. public void setPassword(String password) {
  73. this.password = password;
  74. }
  75.  
  76. public String getUsername() {
  77. return username;
  78. }
  79.  
  80. public void setUsername(String username) {
  81. this.username = username;
  82. }
  83.  
  84. public static void employeeFirstPage() {
  85. System.out.println(
  86. "Бихте желал да пазарувате (въведете '1'), да редактирате цената на стоката в магазина(въведете '2'), или да добавите нова стока(въведете '3')");
  87. String input = App.scan.nextLine();
  88. if (input.contentEquals("1")) {
  89. App.menu();
  90. } else if (input.contentEquals("2")) {
  91. employeeSetPrice();
  92. } else if (input.contentEquals("3")) {
  93. addClothe();
  94. }
  95. else{
  96. System.out.println("Невалидна операция");
  97. }
  98. }
  99.  
  100. //Служители - вход
  101. public static void getEmployee(String enteredEmailOrUsername, String enteredPassword) {
  102. boolean bEmployee = true;
  103. for (Employee emp : emps) {
  104. if ((emp.email.equalsIgnoreCase(enteredEmailOrUsername) && emp.password.equals(enteredPassword))
  105. || (emp.username.equals(enteredEmailOrUsername) && emp.password.equals(enteredPassword))) {
  106. System.out.println("Добре дошъл, " + emp.name + "!");
  107. bEmployee = false;
  108. employeeFirstPage();
  109. }
  110.  
  111. }
  112. if (bEmployee) {
  113. System.out.println("Няма такъв потребител или сте въвели грешни данни.");
  114. App.main(null);
  115. }
  116. }
  117.  
  118.  
  119. //Служителите редактират цена (продукта да се избира по сериен номер)
  120. public static void employeeSetPrice() {
  121.  
  122. int currentProduct = 0;
  123. int serialNum = 0;
  124. for (Clothes cl : Clothes.clothesStorage) {
  125. cl.getAllClothesEmpV(currentProduct);
  126. currentProduct++;
  127. }
  128. currentProduct = 0;
  129. System.out.println("Ако искате да прекратите сегашната функция, напишете '-1'.");
  130.  
  131. while (serialNum != -1) {
  132. System.out.println("Изберете един продукт по серийния му номер.");
  133. serialNum = App.scan.nextInt();
  134. if(serialNum == -1){
  135. for (Clothes cl : Clothes.clothesStorage) {
  136. cl.getAllClothesEmpV(currentProduct);
  137. currentProduct++;
  138.  
  139. }
  140. employeeFirstPage();
  141.  
  142. }
  143. if (serialNum > -1) {
  144. System.out.println("Избрахте следния продукт : ");
  145. System.out.println(Clothes.clothesStorage.get(serialNum).toString());
  146. System.out.print("Въведете новата цена на продукта : ");
  147. double ePrice = App.scan.nextDouble();
  148. System.out.println("");
  149. if (ePrice == Clothes.clothesStorage.get(serialNum).getClothePrice()) {
  150. System.out.println("Цената остана същата.");
  151. } else if (ePrice != Clothes.clothesStorage.get(serialNum).getClothePrice() && ePrice >= 0) {
  152. Clothes.clothesStorage.get(serialNum).setClothePrice(ePrice);
  153. System.out.println("Променихте цената успешно.");
  154. } else if(serialNum < -1){
  155. System.out.println("Невалидна сума.");
  156. }
  157. }
  158. }
  159.  
  160.  
  161.  
  162.  
  163. }
  164.  
  165.  
  166. //Служителите да добавят нови дрехи
  167. public static void addClothe(){
  168. System.out.println("Вид : ");
  169. String type = App.scan.nextLine();
  170. System.out.println("Размер : ");
  171. String size = App.scan.nextLine();
  172. System.out.println("Марка : ");
  173. String brand = App.scan.nextLine();
  174. System.out.println("Цвят : ");
  175. String color = App.scan.nextLine();
  176. System.out.println("Цена : ");
  177. double price = Double.parseDouble(App.scan.nextLine());
  178. System.out.println("Сезон : ");
  179. String season = App.scan.nextLine();
  180. System.out.println("Пол : ");
  181. String gender = App.scan.nextLine();
  182. Clothes c1 = new Clothes(type, size, brand, color, price, season, gender);
  183. Clothes.clothesStorage.add(c1);
  184. System.out.println("Успешно добавена стока!");
  185. c1.getAllInfo();
  186. employeeFirstPage();
  187.  
  188. }
  189.  
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement