SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | * Copyright (c) 2014 Sergi Granell | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | * of this software and associated documentation files (the "Software"), to deal | |
6 | * in the Software without restriction, including without limitation the rights | |
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | * copies of the Software, and to permit persons to whom the Software is | |
9 | * furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
20 | * THE SOFTWARE. | |
21 | */ | |
22 | ||
23 | #include "Cjt_estudiants.hpp" | |
24 | ||
25 | void redondear_e_a(Estudiant & est); | |
26 | /* Pre: est tiene nota */ | |
27 | /* Post: est pasa a tener su nota original redondeada */ | |
28 | ||
29 | int main() | |
30 | { | |
31 | Cjt_estudiants cjt; | |
32 | cout << "Escriu la mida del conjunt i els elements" << endl; | |
33 | ||
34 | cjt.llegir_cjt_estudiants(); | |
35 | int opcio = 0; | |
36 | while (opcio != -6) { | |
37 | cout << "Escriu una opcio: " << endl; | |
38 | opcio = readint(); | |
39 | switch (opcio) { | |
40 | case -1: { | |
41 | cout << "Escriu un estudiant:" << endl; | |
42 | Estudiant e; | |
43 | e.llegir_estudiant(); | |
44 | cjt.afegir_estudiant(e); | |
45 | break; | |
46 | } | |
47 | case -2: { | |
48 | int dni = readint(); | |
49 | if (cjt.existeix_estudiant(dni)) { | |
50 | Estudiant e = cjt.consultar_estudiant(dni); | |
51 | if (e.te_nota()) | |
52 | cout << "El estudiant " << dni << " te nota " << e.consultar_nota() << endl; | |
53 | else | |
54 | cout << "El estudiant " << dni << " no te nota" << endl; | |
55 | } else { | |
56 | cout << "El estudiant " << dni << " no existeix" << endl; | |
57 | } | |
58 | break; | |
59 | } | |
60 | case -3: { | |
61 | cout << "Escriu el DNI i la nova nota: "; | |
62 | int dni = readint(); | |
63 | double nota = readdouble(); | |
64 | if (cjt.existeix_estudiant(dni)) { | |
65 | Estudiant e = cjt.consultar_estudiant(dni); | |
66 | if (e.te_nota()) | |
67 | e.modificar_nota(nota); | |
68 | else | |
69 | e.afegir_nota(nota); | |
70 | cjt.modificar_estudiant(e); | |
71 | } else { | |
72 | cout << "El estudiant " << dni << " no existeix" << endl; | |
73 | } | |
74 | break; | |
75 | } | |
76 | case -4: { | |
77 | for (int i = 1; i <= cjt.mida(); ++i) { | |
78 | Estudiant e = cjt.consultar_iessim(i); | |
79 | if (e.te_nota()) { | |
80 | redondear_e_a(e); | |
81 | cjt.modificar_iessim(i, e); | |
82 | } | |
83 | } | |
84 | break; | |
85 | } | |
86 | case -5: | |
87 | cjt.escriure_cjt_estudiants(); | |
88 | break; | |
89 | } | |
90 | } | |
91 | } |