Exemple #1
0
        public void addStudent(Student s)
        {
            /*
             * pre cond: s of type Student
            * post cond: -
            *
            * Adds on top of the stack a student object
            */

            stack.push(s);
        }
Exemple #2
0
        public void push(Student s)
        {
            /*
             * pre cond: s of type Student
             * post cond: -
             *
             * adds object on top of stack; if maximum capacity is reached,
             * it doubles it
             */

            size++;
            if (size == capacity)
                increaseCapacity();
            students[size] = s;
        }
Exemple #3
0
        public String addStudent(String name, int id, int grade)
        {
            /*
             * Asks validator if the student id is already used
             * returns string if so
             * if not, repository is called and student object is added
             *
             * pre cond: string name, int id, int grade (of the student)
             * post cond: string with status message
             */

            if (this.val.nameIsEmpty(name))
                return "Name cannot be empty!";
            if (this.val.studentExists(id))
                return "Student id already exists!";
            Student s = new Student(name, id, grade);
            this.repo.addStudent(s);
            return "Student added successfully!";
        }