fixed all problems from graded feedback
This commit is contained in:
parent
72512590e3
commit
3486c43f4a
@ -93,16 +93,7 @@ public class School {
|
|||||||
return true;
|
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) {
|
public String getInstructor(int id) {
|
||||||
// find the instructor name given an id
|
// find the instructor name given an id
|
||||||
@ -131,6 +122,16 @@ public class School {
|
|||||||
|
|
||||||
return sum / (float)count;
|
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) {
|
public void courseInfo(int id) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -168,18 +169,24 @@ public class School {
|
|||||||
public boolean courseEmpty(int courseID) {
|
public boolean courseEmpty(int courseID) {
|
||||||
for(Student s : this.studentList) {
|
for(Student s : this.studentList) {
|
||||||
if(s.grades.get(courseID) != null) {
|
if(s.grades.get(courseID) != null) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public boolean deleteCourse(int id) {
|
public boolean deleteCourse(int id) {
|
||||||
for(int i =0;i<this.courseList.size();i++) {
|
if(!courseEmpty(id)) {
|
||||||
if(this.courseEmpty(this.courseList.get(i).id)) {
|
System.out.println("Course " + id + " is not empty!");
|
||||||
if(this.courseList.get(i).id == id) {
|
return false;
|
||||||
this.courseList.remove(i);
|
}
|
||||||
return true;
|
// 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;
|
return false;
|
||||||
@ -248,10 +255,19 @@ public class School {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public void drop(int studentID, int courseID) {
|
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) {
|
public void assign(int instructorID, int courseID) {
|
||||||
|
Course c = getCourse(courseID);
|
||||||
|
c.instructorID = instructorID;
|
||||||
}
|
}
|
||||||
public void unassign(int instructorID, int courseID) {
|
public void unassign(int instructorID, int courseID) {
|
||||||
|
Course c = getCourse(courseID);
|
||||||
|
c.instructorID = 0;
|
||||||
}
|
}
|
||||||
// basic printout of school infor
|
// basic printout of school infor
|
||||||
public void schoolInfo() {
|
public void schoolInfo() {
|
||||||
|
Loading…
Reference in New Issue
Block a user