Skip to content
chicu123 edited this page Sep 13, 2010 · 2 revisions

struct NumeMaterie
{
  string materie;
}

struct Nota extends NumeMaterie  // va obtine automat proprietatile lui NumeMaterie
{
  int nota;
}

struct Student
{
  string nume;
  vector.<Nota> note;
}

vector.<Student> studenti = vector.<Student>(10); // 10 e dimensiunea vectorului
studenti[0] = Student();
studenti[0].nume = "Marian";
studenti[0].note = vector.<Nota>(1);
studenti[0].note[0] = Nota();
studenti[0].note[0].materie = "MDS";
studenti[0].note[0].nota = "5"; // <- programul converteste automat "5" la int 5

string afisareNote(vector.<Nota> note)
{
    string rezultat = "";
    int i;
    for (i=0; i<note.size; ++i)
    {
        if (i>0)
          rezultat = rezultat + ", ";
        rezultat = rezultat + note[i].materie + " - " + note[i].nota;
    }
    return rezultat;
}

string afisareStudent(Student student)
{
   return student.nume  + ": " + afisareNote(student.note);
}
method afisareStudenti(vector.<Student> studenti)
{
    int i=0;
    while (i<studenti.size)
    {
        if (!(studenti[i] == null))
        {
            debug afisareStudent(studenti[i]);
        }
        i++;
    }
}
afisareStudenti(studenti);

output generat in consola


Marian: MDS - 5

Clone this wiki locally