#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int const nota_minima_de_aprovacao = 10;
int const nota_maxima = 20;

inline bool positiva(int const nota) 
{
    return nota >= nota_minima_de_aprovacao;
}

class Aluno {
  public:
    Aluno(string const& nome, int numero, int nota = nota_maxima);
  
    string const& nome() const;
    int numero() const;
    int nota() const;

    void alteraNomePara(string const& novo_nome);
    void alteraNumeroPara(int novo_numero);
    void alteraNotaPara(int nova_nota);

private:
    string nome_;
    int numero_;
    int nota_;
};

inline Aluno::Aluno(string const& nome, int const numero,
                    int const nota)
    : nome_(nome), numero_(numero), nota_(nota) 
{
    assert(0 <= nota and nota <= nota_maxima);
}

inline string const& Aluno::nome() const 
{
    return nome_;
}

inline int Aluno::numero() const 
{
    return numero_;
}

inline int Aluno::nota() const 
{
    return nota_;
}

inline void Aluno::alteraNomePara(string const& novo_nome) 
{
    nome_ = novo_nome;
}

inline void Aluno::alteraNumeroPara(int const novo_numero) 
{
    numero_ = novo_numero;
}

inline void Aluno::alteraNotaPara(int const nova_nota) 
{
    nota_ = nova_nota;
}

inline ostream& operator << (ostream& saida, Aluno const& aluno) 
{
    return saida << aluno.nome() << ' ' << aluno.numero() << ' '
                 << aluno.nota();
}

istream& operator >> (istream& entrada, Aluno& aluno) 
{
    int novo_numero, nova_nota;
    string novo_nome;
    entrada >> novo_nome >> novo_numero >> nova_nota;

    aluno.alteraNomePara(novo_nome);
    aluno.alteraNumeroPara(novo_numero);
    aluno.alteraNotaPara(nova_nota);

    return entrada;
}

int main() 
{
    ofstream canal_para_escrever_a_pauta("pauta.txt");

    Aluno manelito("Manelito", 17);

    canal_para_escrever_a_pauta << manelito;
    canal_para_escrever_a_pauta.close();

    ifstream canal_para_ler_a_pauta("pauta.txt");

    Aluno manelito_guardado("",0);

    canal_para_ler_a_pauta >> manelito_guardado;

    if(manelito.numero() != manelito_guardado.numero() or
       manelito.nome() != manelito_guardado.nome() or
       manelito.nota() != manelito_guardado.nota())
        cerr << "Erro na recuperação do aluno." << endl;

    cout << "Teste terminado." << endl;
}