D
1 - redesign the basic method toString() responsible for the text presentation of the facility.2 - create the right method of the press, such as print(s), which will simply remove to the console what we have received in p.1. this is an index to the object itself, the method of which is called.3 - correct the errors in the creation of a mass (vk@primer,ru) some strange comma. 4 - Remove the volume and seal the text message.The names of variables and the implementation of the text message remain original.public class Employee {
// это поля класса
String name; //ФИО
String position; //должность
String email; //емейл
String phone_number; //номер телефона
int salary; //зарплата
int age; //возраст
// это конструктор
public Employee(String name, String position, String email, String phone_number, int salary, int age) {
this.name = name;
this.position = position;
this.email = email;
this.phone_number = phone_number;
this.salary = salary;
this.age = age;
}
// это переопределенный метод
@Override
public String toString(){
return String.format("Имя: %s \tДолжность: %s \nEmail: %s \t Номер телефона: %s \n Зарплата: %d \t Возраст: %d \n",
name, position, email, phone_number, salary, age);}
// это метод вывода в консоль (как по заданию)
public void print(){
System.out.println(this);
}
public static void main(String[] args) {
Employee[] persArray = new Employee[5];
persArray[0] = new Employee("Вячеслав Кобрин", "Генеральный директор", "vk@primer,ru", "+79996665544", 250000, 55);
persArray[1] = new Employee("Иван Зайцев", "Директор по развитию", "vz@primer,ru", "+79998884455", 127000, 42);
persArray[2] = new Employee("Дмитрий Медведев", "Охранник", "dm@primer,ru", "+79997771234", 19000, 21);
persArray[3] = new Employee("Олеся Лисина", "Ведущий разработчик", "ol@primer,ru", "+79995554789", 120000, 28);
persArray[4] = new Employee("Кристина Волкова", "Директор по работе с клиентами", "kv@primer,ru", "+79994445896", 138000, 48);
// если у объекта в ячейке i поле age > 40, то у него вызывается метод print()
for (int i=0; i < persArray.length; i++)
if (persArray[i].age > 40) persArray[i].print();
}
}