Exemplo n.º 1
0
 def remove(self, Student):
     '''
     removes a student based on it's object. uses removeById method
     input: Student - the object to be removed
     no output
     '''
     if self.findById(Student.getID()) == None:
         raise StudentError("Student ID not found; cannot delete")
     else:
         return (self.removeById(Student.getID()))
Exemplo n.º 2
0
 def testStudentClass(self):
     a = Student("1", "Joe",
                 916)  #real professional testing right here, folks.
     assert a.getID() == "1"
     assert a.getName() == "Joe"
     assert a.getGroup() == 916
     a.setGroup(69)
     a.setID("69")
     a.setName("Bob")
     assert a.getID() == "69"
     assert a.getName() == "Bob"
     assert a.getGroup() == 69
Exemplo n.º 3
0
 def findGradeByAssign(self, Student, listAssign):
     '''
     finds grade of each student by his assignments
     '''
     for counter in range(0, len(listAssign)):
         if Student.getID() == listAssign[counter].getID():
             return listAssign[counter].getGrade()
Exemplo n.º 4
0
    def findIndex(self, Student):
        '''
        finds the index of the Student object
        output: the index in the repository (of the Student object)
        '''

        for counter in range(0, len(self)):
            if self._data[counter].getID() == Student.getID():
                return counter
Exemplo n.º 5
0
 def add(self, Student):
     '''
     adds a new student to the repository
     input: Student object
     '''
     if self.findById(Student.getID()) != None:
         raise StudentError("Duplicate ID")
     else:
         self._data.append(Student)