Barbaris
Профи
(835)
11 месяцев назад
abstract class Worker {
protected String name;
protected String profession;
protected int salaryLevel;
public Worker(String name, String profession, int salaryLevel) {
this.name = name;
this.profession = profession;
this.salaryLevel = salaryLevel;
}
public abstract void myOccupation();
}
class Engineer extends Worker {
public Engineer(String name, int salaryLevel) {
super(name, "Engineer", salaryLevel);
}
@Override
public void myOccupation() {
System.out.println("I am an Engineer. I design and build various structures and systems.");
}
}
public class Main {
public static void main(String[] args) {
Engineer engineer = new Engineer("John", 3);
engineer.myOccupation();
System.out.println("Name: " + engineer.name);
System.out.println("Profession: " + engineer.profession);
System.out.println("Salary Level: " + engineer.salaryLevel);
}
}
Помогите пожалуйста!