Advertisement
Carotte

file

Nov 10th, 2020
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. class File:
  2.     def __init__(self):
  3.         self.valeurs=[]
  4.    
  5.     def enfiler(self,valeur):
  6.          self.valeurs.append(valeur)
  7.          
  8.     def defiler(self):
  9.          if self.valeurs:
  10.              return self.valeurs.pop(0)
  11.    
  12.     def estVide(self):
  13.         return self.valeurs==[]
  14.    
  15.     def longueur(self):
  16.         return len(self.valeurs)
  17.  
  18.     def __str__(self):
  19.         ch="\n Etat de la file: \n"
  20.         for x in self.valeurs:
  21.             ch+= str(x)+""
  22.         return ch
  23.  
  24. q=File()
  25. q.enfiler(9)
  26. q.enfiler(2)
  27. q.enfiler(5)
  28. print(q)
  29. q.defiler()
  30. q.enfiler(7)
  31. print ("la file est-t-elle vide:",q.estVide())
  32. print(q)
  33. print("Longuer de la file: ", q.longueur)    
  34.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement