-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexemplu_clase.py
96 lines (71 loc) · 2.43 KB
/
exemplu_clase.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import random
nume = ["Ionescu", "Munteanu", "Toth", "Kiss", "Schmidt", "Smith"]
prenume = ["Ion", "Andrei", "David", "Vlad", "Robert", "Mihai"]
varste = range(13, 19, 1)
clase = [7,8,9,10,11,12]
scoli = ["Scoala Balcescu", "Scoala Dacia", "Scoala Oltea Doamna", "Liceul Emanuil Gojdu", "Liceul Mihai Eminscu", "Scoala Generala 16"]
discipline = ["romana", "matematica", "engleza", "fizica", "informatica"]
elevi =[]
class Elev:
def __init__(self):
self.nume = None
self.varsta = None
self.clasa = None
self.scoala = None
self.catalog = Catalog()
def identificare(self):
return "{}, {} ani, in clasa {} la {}".format(self.nume, self.varsta, self.clasa, self.scoala)
def getNume(self):
return self.nume
def setNume(self, nume):
self.nume = nume
def getVarsta(self):
return self.varsta
def setVarsta(self, varsta):
self.varsta = varsta
def getClasa(self):
return self.clasa
def setClasa(self, clasa):
self.clasa = clasa
def getScoala(self):
return self.scoala
def setScoala(self, scoala):
self.scoala =scoala
class Catalog:
def __init__(self):
self.romana = []
self.matematica = []
self.engleza = []
self.fizica = []
self.informatica = []
def addRomana(self, nota):
self.romana.append(nota)
def addMatematica(self, nota):
self.matematica.append(nota)
def addFizica(self, nota):
self.fizica.append(nota)
def addEngleza(self, nota):
self.engleza.append(nota)
def addInfo(self, nota):
self.informatica.append(nota)
def getMedieRomana(self):
if self.romana != None:
sum = 0
for k in range(len(self.romana)):
sum += self.romana[k]
medie = sum/len(self.romana)
return medie
return "Nu are note la Limba Romana"
for i in range(30):
elevi.append(Elev())
elevi[i].setNume("{} {}".format(random.choice(nume), random.choice(prenume)))
elevi[i].setVarsta(random.choice(varste))
elevi[i].setClasa(random.choice(clase))
elevi[i].setScoala(random.choice(scoli))
for i in range(30):
for j in range(random.randrange(3,7)):
elevi[i].catalog.addRomana(random.randrange(4,11))
# for i in range(30):
# print(elevi[i].catalog.romana)
print(elevi[13].catalog.romana)
print(elevi[13].catalog.getMedieRomana())