New changelist

This commit is contained in:
sidya82 2014-12-23 11:37:14 +01:00
parent 6e19ca602f
commit 3f5c766e2f
2 changed files with 89 additions and 8 deletions

View File

@ -1,17 +1,55 @@
__author__ = 'sidya'
from src.m.Place import Place, TypePlace, ListeTypePlace
class Parking :
def __init__(self, placesParNiv, nbNiv):
self.__nbPlacesParNiveau = placesParNiv
class Parking:
"""
Definie un parking
"""
def __init__(self, nbNiv, typePlacesParNiv):
#self.__nbPlacesParNiveau = placesParNiv
self.__prix = 10
self.__nbNiveaux = nbNiv
self.__Places = {}
for n in range(0, nbNiv):
l = []
for t in typePlacesParNiv.liste:
for i in range(0, t.nb):
l.append(Place(i+1, n, t.longueur, t.hauteur))
self.__Places[n+1] = l
def recherchePlace(self,voiture):
pass
def recherchePlace(self, voiture):
trouve = False
for i in range(0, self.__nbNiveaux):
if trouve :
break
l = [p for p in self.__Places[i].estLibre]
for p in l :
if p.dimValide(voiture.hauteur, voiture.longueur) :
pass
trouve = True
break
return trouve
def nbPlacesLibresParNiveau(self, niveau):
pass
def nbPlacesLibresNiveau(self, niveau):
i = 0
for p in self.__Places[niveau]:
if p.estLibre:
i += 1
return i
def addAbonnement(self, Abonnement):
pass
def __str__(self):
return "Parking : niveau : " + str(self.__nbNiveaux)
if __name__ == "__main__":
l = ListeTypePlace()
l.add(10, 11, 5)
l.add(7, 12, 5)
p = Parking(5, l)
print(p)
print(p.nbPlacesLibresNiveau(1))

View File

@ -6,8 +6,51 @@ class Place :
self.__numero = numero
self.__niveau = niveau
self.__longueur = longueur
self.__estLibre = True
self.__hauteur = hauteur
self.__estLibre = True
self.__estReserver = False
@property
def estLibre(self):
return self.__estLibre
@property
def estReserver(self):
return self.__estReserver
def dimValide(self,h,l):
return h<self.__hauteur and l<self.__longueur
def addPlacement(self, placement):
pass
class TypePlace :
def __init__(self,h,l,nb):
self.__hauteur = h
self.__longueur = l
self.__nb = nb
@property
def hauteur(self):
return self.__hauteur
@property
def longueur(self):
return self.__longueur
@property
def nb(self):
return self.__nb
class ListeTypePlace :
def __init__(self):
self.l = []
def add(self,h,l,nb):
self.l.append(TypePlace(h,l,nb))
@property
def liste(self):
return self.l