// Lee órdenes de la entrada y las aplica al registro. Se compara con ../c/driver.c.
#include <cstddef>
#include <iostream>
#include <string>

#include "grade_book.h"

int main() {
    GradeBook book;
    std::string command;
    while (std::cin >> command) {
        std::string name;
        int grade = 0;
        if (command == "add") {
            std::cin >> name >> grade;
            std::cout << (book.add(name, grade) ? 1 : 0) << "\n";
        } else if (command == "set") {
            std::cin >> name >> grade;
            std::cout << (book.set_grade(name, grade) ? 1 : 0) << "\n";
        } else if (command == "get") {
            std::cin >> name;
            std::cout << book.grade_of(name) << "\n";
        } else if (command == "remove") {
            std::cin >> name;
            std::cout << (book.remove(name) ? 1 : 0) << "\n";
        } else if (command == "list") {
            std::cout << book.size() << ":";
            for (std::size_t i = 0; i < book.size(); i++) {
                std::cout << " " << book.name_at(i);
            }
            std::cout << "\n";
        }
    }
    return 0;
}
