This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
L3GestionParking/src/m/Voiture.py

59 lines
1.9 KiB
Python
Raw Normal View History

2015-01-13 23:39:12 +00:00
from src.m.connexionBDD import connexionBDD
2015-01-12 15:06:44 +00:00
2015-01-13 23:39:12 +00:00
__author__ = 'sidya'
class Voiture:
2015-02-04 13:20:39 +00:00
def __init__(self, id, idClient=None, longueur=None, hauteur=None, imma=None, estDansParking=False):
2015-01-13 23:39:12 +00:00
if id is None :
2015-02-04 13:20:39 +00:00
self.__idClient = idClient
self.__longueur = longueur
self.__hauteur = hauteur
self.__imma = imma
self.__estDansParking = estDansParking
2015-01-13 23:39:12 +00:00
c = connexionBDD()
2015-02-04 13:20:39 +00:00
c.execute("INSERT INTO voiture (longueur, hauteur, imma, estDansParking) VALUES (?,?,?,?)",
2015-01-13 23:39:12 +00:00
(self.__longueur, self.__hauteur, self.__imma, int(self.__estDansParking)))
self.__id = c.lastId()
c.seDeconnecter()
else:
2015-02-04 13:20:39 +00:00
c = connexionBDD()
r = c.execute("SELECT * FROM voiture WHERE idVoiture='"+str(id)+"'")
row = r.fetchone()
if row is None :
raise IndexError("Invalid id")
c.seDeconnecter()
2015-01-13 23:39:12 +00:00
self.__id = id
2015-02-04 13:20:39 +00:00
self.__idClient = row["idClient"]
self.__longueur = row["longueur"]
self.__hauteur = row["hauteur"]
self.__imma = row["imma"]
self.__estDansParking = row["estDansParking"]
2015-01-12 15:06:44 +00:00
@property
2015-01-13 23:39:12 +00:00
def id(self):
return self.__id
2015-01-12 15:06:44 +00:00
2015-01-12 15:36:26 +00:00
@property
2015-01-13 23:39:12 +00:00
def hauteur(self):
return self.__hauteur
2015-01-12 15:06:44 +00:00
2015-01-12 15:36:26 +00:00
@property
2015-01-13 23:39:12 +00:00
def longueur(self):
return self.__longueur
2015-01-12 15:06:44 +00:00
2015-01-13 23:39:12 +00:00
@property
def immatriculation(self):
2015-02-04 13:20:39 +00:00
return self.__imma
2015-01-12 15:06:44 +00:00
2015-01-13 23:39:12 +00:00
@property
def estDansParking(self):
return self.__estDansParking == True
2015-01-12 15:06:44 +00:00
2015-01-13 23:39:12 +00:00
def __str__(self):
return "[Voiture :" \
2015-02-04 13:20:39 +00:00
" id = " + str(self.__id) + ", " \
" longueur = " + str(self.__longueur) + ", " \
" hauteur = " + str(self.__hauteur) + ", " \
" imma = " + str(self.__imma) + ", " \
" estDansParking = " + str(self.__estDansParking)+"]"