Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
51 changes: 51 additions & 0 deletions src/main/java/students/bryantferguson/Instructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package main.java.students.bryantferguson;

import java.util.ArrayList;
//Instructor class that is a child of Person
public class Instructor extends Person{
//fields of an Instructor
private String department;
private ArrayList<Student> students;

public Instructor(int id, String firstName, String lastName, String email, String department) {
super(id, firstName, lastName, email);
this.department = department;
this.students = new ArrayList<>();
}

//getter method for the department field
public String getDepartment() {
return department;
}

//methods for adding and removing students from Instructor's roster
public void addStudent(Student student){
students.add(student);
}

public void removeStudent(Student student){
students.remove(student);
}

//displays the full contents of the students list
public void displayRoster() {
System.out.println("[Instructor] Dr." + super.getFirstName() + "'s Roster:");
for(Student student : students) {
student.getSummary();
}
System.out.println("****************************************************");
}

//returns whatever value is stored in method
public void createAnnouncement(String message){
System.out.println(message);
}

//method passed down from the parent class that is overwritten to have its own behavior
//displays the info of a student
@Override
public void getSummary(){
System.out.println("[Instructor] Dr. " + super.getFirstName() + " | " + "Department: " + getDepartment());
}

}
50 changes: 50 additions & 0 deletions src/main/java/students/bryantferguson/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main.java.students.bryantferguson;

import java.util.ArrayList;
import java.util.Arrays;

public class Main {
public static void main(String[] args) {

//Instructor objects
Instructor instructor1 = new Instructor(101, "Bryant","Ferguson","bferg@gmail.com", "Computer Science");
Instructor instructor2 = new Instructor(102, "Kerry","Ferguson","kferg@gmail.com", "Computer Science");
Instructor instructor3 = new Instructor(103, "Shawn","Ferguson","sferg@gmail.com", "Computer Science");
ArrayList<Instructor> instructorList = new ArrayList<>(Arrays.asList(instructor1,instructor2,instructor3));

instructor1.getSummary();
instructor2.getSummary();
instructor3.getSummary();
System.out.println("------------------");

//Student objects
Student s1 = new Student(120,"Bob","Jeff", "123@gmail.com",1.1,2);
Student s2= new Student(121,"Fer","Jeff", "222@gmail.com",1.1,2);
Student s3 = new Student(122,"Ray","Jeff", "447@gmail.com",1.1,2);
Student s4 = new Student(120,"Lily","Richards", "444@gmail.com",2.5,3);
Student s5= new Student(121,"Rachel","Richards", "555@gmail.com",2.8,3);
Student s6 = new Student(122,"Susan","Richards", "666@gmail.com",2.9,3);
Student s7 = new Student(120,"Kemain","Brown", "000@gmail.com",3.7,4);
Student s8= new Student(121,"Paul","Brown", "333@gmail.com",3.5,4);
Student s9 = new Student(122,"Rashid","Brown", "111@gmail.com",3.8,4);

//giving each teacher a roster of students
instructor1.addStudent(s1);
instructor1.addStudent(s2);
instructor1.addStudent(s3);
instructor2.addStudent(s4);
instructor2.addStudent(s5);
instructor2.addStudent(s6);
instructor3.addStudent(s7);
instructor3.addStudent(s8);
instructor3.addStudent(s9);

//shows the teacher and their roster of students
instructor1.displayRoster();
instructor2.displayRoster();
instructor3.displayRoster();

//shows the announcement that the instructor made
instructor1.createAnnouncement("Bryant is the BEST instructor!");
}
}
38 changes: 38 additions & 0 deletions src/main/java/students/bryantferguson/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main.java.students.bryantferguson;
//abstract class that outlines what a Person should be like
public abstract class Person {
//fields for a Person
private int id;
private String firstName;
private String lastName;
private String email;

//constructor
public Person(int id, String firstName, String lastName, String email) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}

//getters
public int getId() {
return id;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public String getEmail() {
return email;
}


//method to be passed down to child classes
public abstract void getSummary();
}
39 changes: 39 additions & 0 deletions src/main/java/students/bryantferguson/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main.java.students.bryantferguson;
//Student class that is a child of Person
public class Student extends Person{
//fields for a Student
private int gradeLevel;
private double gpa;

//Constructor
public Student(int id, String firstName, String lastName, String email, double gpa, int gradeLevel) {
super(id, firstName, lastName, email);
this.gpa = gpa;
this.gradeLevel = gradeLevel;
}

//returns if the student is on honor roll
public String isOnHonorRoll(double gpa){
if(gpa >= 3.5){
return "Yes";
}
return "No";
}

//getter methods for the fields
public int getGradeLevel() {
return gradeLevel;
}

public double getGpa() {
return gpa;
}

//method passed down from the parent class that is overwritten to have its own behavior
//displays the info of a student
@Override
public void getSummary(){
System.out.println("[Student] " + super.getFirstName() + " " + super.getLastName() + " |" + " Grade Level: "
+ getGradeLevel() + " | " + "GPA: " + getGpa() + " | " + "Honor Roll: " + isOnHonorRoll(getGpa()));
}
}