def __init__(self, repository):
        '''
        Constructor
        '''

        self.__stud_repository = Student_repository()
        self.__stud_validator = Student_validator()
class Test_Student_repository(TestCase):
    def setUp(self):
        super().setUp()
        self.__repository = Student_repository()

    def test_add_student(self):
        student = Student(1, "Andrei", 916)
        self.__repository.add_student(student)
        self.assertEqual(len(self.__repository.list_all_students()), 1,
                         "There should be 1 student in the test repository!")
Ejemplo n.º 3
0
 def __init__(self, repository):
     '''
     Constructor
     '''
     self.__grade_repository = Grade_repository()
     self.__grade_validator = Grade_validator()
     self.__stud_repository = Student_repository()
     self.__assign_repository = Assignment_repository()
class Student_controller:
    '''
    classdocs
    '''
    def __init__(self, repository):
        '''
        Constructor
        '''
        self.__stud_repository = Student_repository()
        self.__stud_validator = Student_validator()

    def add_student(self, stud_id, name, group):
        stud = Student(stud_id, name, group)
        self.__stud_validator.validate_student(stud)
        self.__stud_repository.add_student(stud)

    def add_sample_data(self):
        self.add_student(1, "Andrei", 916)
        self.add_student(2, "Cristian", 916)
        self.add_student(3, "Catalin", 916)
        self.add_student(4, "Babenco", 915)
        self.add_student(5, "Ramona", 915)
        self.add_student(6, "Lorena", 915)
        self.add_student(7, "Iulia", 915)
        self.add_student(8, "Gandalf", 916)
        self.add_student(9, "Sauron", 916)
        self.add_student(10, "Harry Potter", 916)

    def update_student(self, stud_id, name, group):
        stud = Student(stud_id, name, group)
        self.__stud_validator.validate_student(stud)
        self.__stud_repository.update_student(stud)

    def remove_student_by_id(self, stud_id):
        self.__stud_repository.remove_student_by_id(stud_id)

    def find_student_by_id(self, stud_id):
        stud_with_id = self.__stud_repository.find_student(stud_id)
        return stud_with_id

    def students_length(self):
        return self.__stud_repository.student_length()

    def list_all_students(self):
        return self.__stud_repository.list_all_students()
Ejemplo n.º 5
0
'''
Created on Nov 3, 2016

@author: AndreiMsc
'''

from repository.Student_repository import Student_repository
from controller.Student_controller import Student_controller
from repository.Assignment_repository import Assignment_repository
from controller.Assignment_controller import Assignment_controller
from repository.Grade_repository import Grade_repository
from controller.Grade_controller import Grade_controller
from ui.Commands import Commands
from ui.Menu import Menu
from ui.ui_Selector import ui_Selector

stud_repo = Student_repository()
stud_ctrl = Student_controller(stud_repo)
assign_repo = Assignment_repository()
assign_ctrl = Assignment_controller(assign_repo)
grade_repo = Grade_repository()
grade_ctrl = Grade_controller(grade_repo)
method = ui_Selector.ui_selector()
if method == "command":
    com = Commands(stud_ctrl,assign_ctrl,grade_ctrl)
    com.ui_run()
else:
    menu = Menu(stud_ctrl,assign_ctrl,grade_ctrl)
    menu.ui_run()
 def setUp(self):
     super().setUp()
     self.__repository = Student_repository()
class Student_controller:
    '''
    Controls students repository
    '''
    def __init__(self, repository):
        '''
        Constructor
        '''

        self.__stud_repository = Student_repository()
        self.__stud_validator = Student_validator()

    def add_student(self, stud_id, name, group):
        '''
        Adds a new student to the repository after validating its properties
        Input:
        :param stud_id
        :param name
        :param group
        '''

        stud = Student(stud_id, name, group)
        self.__stud_validator.validate_student(stud)
        self.__stud_repository.add_student(stud)

    def add_sample_data(self):
        '''
        Adds sample students to the repository
        '''

        self.add_student(1, "Andrei", 916)
        self.add_student(2, "Cristian", 916)
        self.add_student(3, "Catalin", 916)
        self.add_student(4, "Babenco", 915)
        self.add_student(5, "Ramona", 915)
        self.add_student(6, "Lorena", 915)
        self.add_student(7, "Iulia", 915)
        self.add_student(8, "Gandalf", 916)
        self.add_student(9, "Sauron", 916)
        self.add_student(10, "Harry Potter", 916)

    def update_student(self, stud_id, name, group):
        '''
        Updates a student from the repository after validating its new properties
        Input:
        :param stud_id
        :param name
        :param group
        '''

        stud = Student(stud_id, name, group)
        self.__stud_validator.validate_student(stud)
        self.__stud_repository.update_student(stud)

    def remove_student_by_id(self, stud_id):
        '''
        Removes the student with the given ID from the repository
        Input:
        :param stud_id
        '''

        self.__stud_repository.remove_student_by_id(stud_id)

    def find_student_by_id(self, stud_id):
        '''
        Finds the student with the given ID
        Input:
        :param stud_id
        Output:
        :return stud_with_id
        '''

        stud_with_id = self.__stud_repository.find_student(stud_id)
        return stud_with_id

    def students_length(self):
        '''
        Returns the number of students
        Output:
        :return self.__stud_repository.student_length()
        '''

        return self.__stud_repository.student_length()

    def list_all_students(self):
        '''
        Makes a list containing all students
        Output:
        :return self.__stud_repository.list_all_students()
        '''

        return self.__stud_repository.list_all_students()
Ejemplo n.º 8
0
class Student_controller:
    '''
    classdocs
    '''
    def __init__(self, repository):
        '''
        Constructor
        '''
        self.__stud_repository = Student_repository()
        self.__stud_validator = Student_validator()

    def add_student(self, stud_id, name, group):
        stud = Student(stud_id, name, group)
        self.__stud_validator.validate_student(stud)
        self.__stud_repository.add_student(stud)

    def update_student(self, stud_id, name, group):
        stud = Student(stud_id, name, group)
        self.__stud_validator.validate_student(stud)
        self.__stud_repository.update_student(stud)

    def remove_student(self, stud_id, name, group):
        stud = Student(stud_id, name, group)
        self.__stud_validator.validate_student(stud)
        self.__stud_repository.remove_student(stud)

    def remove_student_by_id(self, stud_id):
        self.__stud_repository.remove_student_by_id(stud_id)

    def find_student_by_id(self, stud_id):
        return self.__stud_repository.find_student(stud_id)

    def students_length(self):
        return self.__stud_repository.student_length()

    def list_all_students(self):
        return self.__stud_repository.list_all_students()