Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Employee extends Clothes { //За да има достъп до clothesStorage
- static Scanner scan = new Scanner (System.in);
- private static double ePrice;
- private String name, family, egn;
- private static ArrayList<Employee> emps = new ArrayList<>();
- static {
- emps.add(new Employee("Ivan", "Ivanov", "9800000000"));
- emps.add(new Employee("Asen", "Asenov", "8900000000"));
- emps.add(new Employee("Georgi", "Georgiev", "7800000000"));
- }
- public Employee() {
- }
- public Employee(String name, String family, String egn) {
- this.name = name;
- this.family = family;
- this.egn = egn;
- }
- public static double getePrice() {
- return ePrice;
- }
- public static void setePrice(double ePrice) {
- Employee.ePrice = ePrice;
- }
- public String getName() {return name;}
- public void setName(String name) {this.name = name;}
- public String getFamily() {return family;}
- public void setFamily(String family) {this.family = family;}
- public String getEgn() {return egn;}
- public void setEgn(String egn) {this.egn = egn;}
- public static void getEmployee(String enteredName, String enteredFamily, String enteredEgn) {
- boolean bEmployee = true;
- for (Employee emp : emps) {
- if (emp.name.equalsIgnoreCase(enteredName) && emp.family.equalsIgnoreCase(enteredFamily) && emp.egn.contentEquals(enteredEgn)) {
- System.out.println("Влязохте в системата като служител.");
- bEmployee = false;
- employeeSetPrice(ePrice);
- }
- }
- if (bEmployee) {
- System.out.println("Няма такъв потребител или сте въвели грешни данни.");
- }
- }
- public static void employeeSetPrice(double ePrise) {
- for (Clothes cl : clothesStorage) {
- cl.getAllInfo();
- System.out.println("Задайте нова цена или въведете същата.");
- double newPrice = scan.nextDouble();
- if (newPrice == cl.getClothePrice()) {
- System.out.println("Не променихте цената.");
- cl.getAllInfo();
- }else if (newPrice != cl.getClothePrice() && newPrice > 0) {
- cl.setClothePrice(newPrice);
- System.out.println("Променихте цената на продукта. \n Новите данни на продукта: ");
- cl.getAllInfo();
- }else{
- System.out.println("Невалидна сума. ");
- cl.getAllInfo();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement