Last active
April 25, 2020 18:14
-
-
Save SebastianDorobantu/2b17e32bb43af880dbd0a604e5075766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Iterator fabrica de masini pt Examen practic de Sebi Dorobantu | |
Prin introducerea a seriei de inceput a zilei respective si numarului de masini produse arata nr de loturi cat si seriile masinilor cu volan pe stanga/dreapta""" | |
import os | |
import sys | |
class Iterator(): | |
""" | |
Iteratorul propiu zis | |
""" | |
def __init__(self, serie: int, bucati: int): | |
""" | |
:param serie: | |
:param bucati: | |
""" | |
self.serie = serie | |
self.bucati = bucati | |
self.lots = list(range(self.serie // 20, ((self.serie + self.bucati) // 20) + 1)) | |
def __iter__(self): | |
""" | |
:return: | |
""" | |
return self | |
def __next__(self): | |
""" | |
:return: | |
""" | |
if len(self.lots) == 0: | |
raise StopIteration | |
return self.lots.pop(0) | |
class Obiect(): | |
""" | |
Obiectul care va fii creat | |
""" | |
def __init__(self, serieb: int, bucatib: int): | |
""" | |
:param serieb: | |
:param bucatib: | |
""" | |
self.serie = serieb | |
self.bucati = bucatib | |
self.__iter = Iterator(serieb, bucatib) | |
self.dreapta2 = [] | |
self.stanga2 = [] | |
for x in list(range(self.serie, (self.serie + self.bucati))): | |
if (x % 20) < 10: | |
self.dreapta2.append(x) | |
else: | |
self.stanga2.append(x) | |
def __iter__(self): | |
""" | |
:return: | |
""" | |
return self.__iter | |
def dreapta(self): | |
""" | |
Metoda care returneaza seriile masinilor cu volan pe dreapta | |
:return: | |
""" | |
return self.dreapta2 | |
def stanga(self): | |
""" | |
Metoda care returneaza seriile masinilor cu volan pe stanga | |
:return: | |
""" | |
return self.stanga2 | |
obj = Obiect(101, 41) | |
print(obj.stanga()) | |
print(obj.dreapta()) | |
output = open("log.log", 'wt') | |
for line in obj: | |
output.write(str(line) + '\n') | |
output.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment