Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.example;
- public class Student extends Person{
- private int year_stud;
- public Student(String name, int age, int year_stud){
- super(name, age);
- if (year_stud < 0)
- throw new IllegalArgumentException("Amount of studying years must be >= 1");
- this.year_stud = year_stud;
- }
- public int getYear_stud(){
- return year_stud;
- }
- public void setYear_stud(int year_stud){
- if (year_stud < 0)
- throw new IllegalArgumentException("Amount of studying years must be >= 1");
- this.year_stud = year_stud;
- }
- public String toString(){
- return "Student { " + name + " who is " + age + ", studies already: " + year_stud + " years }";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement