fixed all problems from graded feedback

This commit is contained in:
shockrahwow 2019-03-15 02:05:54 -07:00
parent 72512590e3
commit 3486c43f4a

View File

@ -93,16 +93,7 @@ public class School {
return true;
}
public int courseEnrolled(int id) {
// Helper function which simply counts up how many people are enrolled in a given cuorse
int count = 0;
for(Course i : this.courseList) {
if(i.id == id) {
count++;
}
}
return count;
}
public String getInstructor(int id) {
// find the instructor name given an id
@ -131,6 +122,16 @@ public class School {
return sum / (float)count;
}
public int courseEnrolled(int id) {
int count = 0;
for(Student s : this.studentList) {
// everytime a student has the given id in their grades add 1 to the counter
if(s.grades.get(id) != null) {
count++;
}
}
return count;
}
public void courseInfo(int id) {
boolean found = false;
@ -168,18 +169,24 @@ public class School {
public boolean courseEmpty(int courseID) {
for(Student s : this.studentList) {
if(s.grades.get(courseID) != null) {
return true;
return false;
}
}
return true;
}
public boolean deleteCourse(int id) {
for(int i =0;i<this.courseList.size();i++) {
if(this.courseEmpty(this.courseList.get(i).id)) {
if(this.courseList.get(i).id == id) {
this.courseList.remove(i);
return true;
if(!courseEmpty(id)) {
System.out.println("Course " + id + " is not empty!");
return false;
}
// next look for the course to delete
for(int i =0; i<courseList.size();i++) {
if(courseList.get(i).id == id) {
courseList.remove(i);
for(Student s : studentList) {
s.grades.remove(id);
}
return true;
}
}
return false;
@ -248,10 +255,19 @@ public class School {
return true;
}
public void drop(int studentID, int courseID) {
for(Student s : studentList) {
if(s.id == studentID) {
s.grades.remove(courseID);
}
}
}
public void assign(int instructorID, int courseID) {
Course c = getCourse(courseID);
c.instructorID = instructorID;
}
public void unassign(int instructorID, int courseID) {
Course c = getCourse(courseID);
c.instructorID = 0;
}
// basic printout of school infor
public void schoolInfo() {