Advertisement
AntonStanoev

Exercise 2

Oct 28th, 2023
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | Source Code | 0 0
  1. public class Student extends Person {
  2.     private int grade;
  3.  
  4.     public Student(String name, int age, int grade) {
  5.         super(name, age);
  6.         this.grade = grade;
  7.     }
  8.  
  9.     public int getGrade() {
  10.         return grade;
  11.     }
  12.  
  13.     public void setGrade(int grade) {
  14.         this.grade = grade;
  15.     }
  16.  
  17.     @Override
  18.     public void introduce() {
  19.         System.out.println(getName() + ", " + getAge() + " години. Успех: " + grade + ".");
  20.     }
  21.  
  22.     public static void main(String[] args) {
  23.         Student student = new Student("Петър", 25, 5);
  24.         student.introduce();
  25.     }
  26. }
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement