Advertisement
cgorrillaha

Untitled

Mar 15th, 2022
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. package inherit;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. public class Student extends Person{
  6.     private int gpa;
  7.     private ArrayList<String> schedule;
  8.  
  9.     //default constructor calls
  10.     public Student(){
  11.         //here is where Person constructor is called
  12.         super();
  13.         gpa=4;
  14.         schedule=new ArrayList<>();
  15.     }
  16.  
  17.     public Student(String name, int age, String email,
  18.                    int gpa, ArrayList<String>schedule){
  19.         super(name, age, email);
  20.         this.gpa=gpa;
  21.         this.schedule=schedule;
  22.     }
  23.     //explicit constructor calls.
  24.  
  25.     public int getGpa() {
  26.         return gpa;
  27.     }
  28.  
  29.     public void setGpa(int gpa) {
  30.         this.gpa = gpa;
  31.     }
  32.  
  33.     public ArrayList<String> getSchedule() {
  34.         return schedule;
  35.     }
  36.  
  37.     public void setSchedule(ArrayList<String> schedule) {
  38.         this.schedule = schedule;
  39.     }
  40.  
  41.     @Override
  42.     public String toString() {
  43.         return super.toString()+" Student{" +
  44.                 "gpa=" + gpa +
  45.                 ", schedule=" + schedule +
  46.                 '}';
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement