codehs java9 2 6 students part 1 studenttester java

Solutions on MaxInterview for codehs java9 2 6 students part 1 studenttester java by the best coders in the world

showing results for - "codehs java9 2 6 students part 1 studenttester java"
Amanda
17 Nov 2020
1public class StudentTester
2{
3    public static void main(String[] args)
4    {
5        
6        /**
7         * Create a student in the class of 2020
8         */
9         Student bill = new Student("bill", 2020);
10         
11         /**
12         * Create a student athlete in the class of 2022
13         * that is eligible and plays soccer.
14         */
15         StudentAthlete robert = new StudentAthlete("robert", 2022, "soccer", true);
16         
17         // Print out both objects
18    }
19}
Charles
20 May 2018
1public class StudentAthlete extends Student
2{
3    private String sport;
4    private boolean eligible;
5    
6   public StudentAthlete(String name, int classYear, String sport, boolean eligible){
7       super(name, classYear);
8       this.sport = sport;
9       this.eligible = eligible;
10   }
11   
12   
13   public String getSport(){
14       return sport;
15   }
16   
17   public boolean isEligible(){
18       return eligible;
19   }
20    
21    @Override
22    public String toString(){
23        return super.getName() + ", class of " + super.getClassYear() +
24            ", plays " + sport;
25    }
26}
27
Clive
27 Apr 2017
1public class Student
2{
3    private String name;
4    private int classYear;
5   
6   // Constructor goes here
7   public Student(String name, int year){
8       this.name = name;
9       this.classYear = year;
10   }
11   
12    public String getName(){
13       return name;
14    }
15   
16    public int getClassYear(){
17       return classYear;
18    }
19   
20    public String toString(){
21        return name + ", class of " + classYear;
22    }
23}
24