Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Locomotiva:
- def __init__(self,p):
- #constructorul locmotivei
- # self = numarul sub care a fost inregistrata locomotiva in memoria RAM
- self.putereLocomotiva = p
- def __repr__(self):
- return 'Locomotiva de putere {}'.format(self.putereLocomotiva)
- locomotivaLuiRadu = Locomotiva(323)
- print(locomotivaLuiRadu)
- class VagonCalatori:
- def __init__(self,nrMaxP,nrEfP):
- self.nrMaximPasageri = nrMaxP
- self.nrEfectivPasageri = nrEfP
- def __repr__(self):
- return 'Vagon calatori {}/{} pasageri'.format(self.nrMaximPasageri,self.nrEfectivPasageri)
- def greutateVagon(self):
- masaPopulatie = 80 * self.nrEfectivPasageri
- masaTotala = 55 + masaPopulatie / 1000
- return masaTotala
- def venit(self,distanta):
- incasarePersoana = (distanta/100) * 20
- incasareTotal = incasarePersoana * self.nrEfectivPasageri
- return incasareTotal
- vagonBianca = VagonCalatori(80,23)
- vagonAndrei = VagonCalatori(80,45)
- print(vagonBianca)
- print(vagonAndrei)
- print(vagonAndrei.greutateVagon())
- print(vagonBianca.venit(480))
- class VagonMarfa:
- def __init__(self,tonaj,volum,tip):
- self.tonajMarfa = tonaj
- self.volumMarfa = volum
- self.tipMarfa = tip
- def __repr__(self):
- return 'Vagon marfa de tip {} de tonaj {} cu {} volum de marfa'.format(self.tipMarfa,self.tonajMarfa,self.volumMarfa)
- def greutate(self):
- greutateTotala = self.tonajMarfa * 55
- return greutateTotala
- class Tren:
- def __init__(self,nrc,tc,tcbl,tcm,tlm,tlc,tcb,ts):
- self.nrCalatori = nrc
- self.tonajCereale = tc
- self.tonajCombustibil = tcbl
- self.tonajCiment = tcm
- self.tonajLichide = tlc
- self.tonajLemn = tlm
- self.tonajCarbune = tcb
- self.tonajSpuma = ts
- self.locomotive = []
- self.vagoaneMarfa = []
- self.vagoanePersoane = []
- def adaugaLocomotiva(self,l):
- self.locomotive.append(l)
- def adaugaVagonMarfa(self,v):
- self.vagoaneMarfa.append(v)
- def adaugaVagonPersoane(self,v):
- self.vagoanePersoane.append(v)
- def __repr__(self):
- t = self.tonajSpuma + self.tonajCarbune + self.tonajCiment + self.tonajLemn + self.tonajLichide + self.tonajCiment + self.tonajCombustibil + self.tonajCereale
- return 'Trenul transporta {} calatori si {} tone de marfa.'.format(self.nrCalatori, t)
- def nrVagoaneCalatori(self):
- n = self.nrCalatori // 80
- if self.nrCalatori % 80 == 0:
- return n
- else:
- return n + 1
- def nrVagoaneMarfa(self):
- k = 0
- volumCereale1 = (self.tonajCereale * 1000) / 600
- volumCereale2 = (self.tonajCereale * 1000) // 600
- if volumCereale2 == volumCereale1 and volumCereale1 != 0:
- n = volumCereale1 // 300
- # 300 este volumul maxim admis al unui vagon
- k = k + n
- elif volumCereale1 != volumCereale2:
- # sunt in situatia de impartie cu virgula
- n = volumCereale1 // 300
- k = k + n + 1
- volumCombustibil1 = (self.tonajCombustibil * 1000) / 600
- volumCombustibil2 = (self.tonajCombustibil * 1000) // 600
- if volumCombustibil1 == volumCombustibil2 and volumCombustibil1 != 0:
- n = volumCombustibil1 // 300
- k += n
- elif volumCombustibil1 != volumCombustibil2:
- n = volumCombustibil1 // 300
- k += n + 1
- volumCiment1 = (self.tonajCiment * 1000) / 600
- volumCiment2 = (self.tonajCiment * 1000) // 600
- if volumCiment2 == volumCiment1 and volumCiment1 != 0:
- n = volumCiment1 // 300
- k += n
- elif volumCiment1 != volumCiment2:
- n = volumCiment1 // 300
- k += n + 1
- volumLichide1 = (self.tonajLichide * 1000) / 600
- volumLichide2 = (self.tonajLichide * 1000) // 600
- if volumLichide2 == volumLichide1 and volumLichide1 != 0:
- n = volumLichide1 // 300
- k += n
- elif volumLichide1 != volumLichide2:
- n = volumLichide1 // 300
- k += n + 1
- volumLemn1 = (self.tonajLemn * 1000) / 600
- volumLemn2 = (self.tonajLemn * 1000) // 600
- if volumLemn2 == volumLemn1 and volumLemn1 != 0:
- n = volumLemn1 // 300
- k += n
- elif volumLemn2 != volumLemn1:
- n = volumLemn1 // 300
- k += n + 1
- volumCarbune1 = (self.tonajCarbune * 1000) / 600
- volumCarbune2 = (self.tonajCarbune * 1000) // 600
- if volumCarbune2 == volumCarbune1 and volumCarbune1 != 0:
- n = volumCarbune2 // 300
- k += n
- elif volumCarbune2 != volumCarbune1:
- n = volumCarbune1 // 300
- k += n + 1
- volumSpuma1 = (self.tonajSpuma * 1000) / 600
- volumSpuma2 = (self.tonajSpuma * 1000) //600
- if volumSpuma2 == volumSpuma1 and volumSpuma1 != 0:
- n = volumSpuma1 // 300
- k += n
- elif volumSpuma1 != volumSpuma2:
- n = volumSpuma1 // 300
- k += n + 1
- return k
- def nrLocomotive(self):
- p = self.nrVagoaneCalatori()
- greutatePersoane = (p*80)/1000
- greutateVagoanePersoane = 85 * self.nrVagoaneCalatori()
- greutateTotalaPersoane = greutatePersoane + greutateVagoanePersoane
- greutateMarfa = self.tonajCereale + self.tonajCarbune + self.tonajCombustibil + self.tonajCiment + self.tonajLichide + self.tonajLemn + self.tonajSpuma
- greutateVagonMarfa = self.nrVagoaneMarfa() * 55
- greutateTotalaMarfa = greutateMarfa + greutateVagonMarfa
- total = greutateTotalaMarfa + greutateTotalaPersoane
- if total % 1000 == 0:
- return total//1000
- else:
- return total//1000 + 1
- class Calatorie:
- def __init__(self,l,nrc,costLocomotiva,costPasager,tc,tcbl,tcm,tlc,ts,tlm,tcb):
- self.distanta = l
- self.nrCalatori = nrc
- self.costLocomotiva = costLocomotiva
- self.CostPasager = costPasager
- self.tren = Tren(nrc,tc,tcbl,tcm,tlm,tlc,tcb,ts)
- nrLocomotive= self.tren.nrLocomotive()
- for i in range(0,int(nrLocomotive)):
- l = Locomotiva(1000)
- self.tren.adaugaLocomotiva(l)
- nrVagonMarfa = self.tren.nrVagoaneMarfa()
- for i in range(0,int(nrVagonMarfa)):
- v = VagonMarfa(30,500,'marfa')
- self.tren.adaugaVagonMarfa(v)
- nrVagonPersoane = self.tren.nrVagoaneCalatori()
- for i in range(0,nrVagonPersoane):
- v = VagonCalatori(80,23)
- self.tren.adaugaVagonPersoane(v)
- def incasari(self):
- tt = self.tren.tonajCereale + self.tren.tonajCiment + self.tren.tonajLichide + self.tren.tonajLemn + self.tren.tonajCarbune + self.tren.tonajCombustibil + self.tren.tonajSpuma
- incasariMarfa = tt * 40 * (self.distanta/100)
- incasariPersoane = self.nrCalatori * 100 * (self.distanta/100)
- return incasariMarfa + incasariPersoane
- def cheltuieli(self):
- return self.tren.nrLocomotive() * 1000 * (self.distanta/100)
- def profit(self):
- return self.incasari() - self.cheltuieli()
- tren = Tren(80,2,5,1,7,4,6,7)
- print(tren)
- print(tren.nrVagoaneMarfa())
- print(tren.nrLocomotive())
- c = Calatorie(480,1000,100,2,5,1,7,4,6,7,5)
- print(c.profit())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement