public abstract class Person {
String name;
int age;
int height;
String department;
public abstract void sayHi();
public void describePerson(){
System.out.println(
name + " is " + age + " old and is " + height + " tall. " +
"Works in " + department + " department"
);
}
}
public class Student extends Person {
@Override
public void sayHi() {
System.out.println("Good morning, sir! My name is " + name + " and I'm a student");
}
public void haveAParty(){
System.out.println("Party time! BYOB!");
}
}
public class Docent extends Person {
@Override
public void sayHi() {
System.out.println("Yo, mate! I'm a docent. Respect my authority!");
}
public void makeStudentsSuffer(){
System.out.println("You shall not pass!");
}
}
public class Main {
public static void main(String[] args) {
Student vasiliy = new Student();
vasiliy.name = "Vasiliy";
vasiliy.age = 21;
vasiliy.department = "Year 3";
vasiliy.height = 178;
Docent alexandrPetrovich = new Docent();
alexandrPetrovich.name = "Alexandr Petrovich";
alexandrPetrovich.age = 38;
alexandrPetrovich.height = 172;
alexandrPetrovich.department = "Kafedra OOP";
vasiliy.sayHi();
vasiliy.haveAParty();
alexandrPetrovich.sayHi();
alexandrPetrovich.makeStudentsSuffer();
}
}