Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (c) 2014 Sergi Granell
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- #include "Cjt_estudiants.hpp"
- void redondear_e_a(Estudiant & est);
- /* Pre: est tiene nota */
- /* Post: est pasa a tener su nota original redondeada */
- int main()
- {
- Cjt_estudiants cjt;
- cout << "Escriu la mida del conjunt i els elements" << endl;
- cjt.llegir_cjt_estudiants();
- int opcio = 0;
- while (opcio != -6) {
- cout << "Escriu una opcio: " << endl;
- opcio = readint();
- switch (opcio) {
- case -1: {
- cout << "Escriu un estudiant:" << endl;
- Estudiant e;
- e.llegir_estudiant();
- cjt.afegir_estudiant(e);
- break;
- }
- case -2: {
- int dni = readint();
- if (cjt.existeix_estudiant(dni)) {
- Estudiant e = cjt.consultar_estudiant(dni);
- if (e.te_nota())
- cout << "El estudiant " << dni << " te nota " << e.consultar_nota() << endl;
- else
- cout << "El estudiant " << dni << " no te nota" << endl;
- } else {
- cout << "El estudiant " << dni << " no existeix" << endl;
- }
- break;
- }
- case -3: {
- cout << "Escriu el DNI i la nova nota: ";
- int dni = readint();
- double nota = readdouble();
- if (cjt.existeix_estudiant(dni)) {
- Estudiant e = cjt.consultar_estudiant(dni);
- if (e.te_nota())
- e.modificar_nota(nota);
- else
- e.afegir_nota(nota);
- cjt.modificar_estudiant(e);
- } else {
- cout << "El estudiant " << dni << " no existeix" << endl;
- }
- break;
- }
- case -4: {
- for (int i = 1; i <= cjt.mida(); ++i) {
- Estudiant e = cjt.consultar_iessim(i);
- if (e.te_nota()) {
- redondear_e_a(e);
- cjt.modificar_iessim(i, e);
- }
- }
- break;
- }
- case -5:
- cjt.escriure_cjt_estudiants();
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement