Advertisement
Guest User

classe.py

a guest
Jan 22nd, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. class Oggetto:
  2.     Pz=0
  3.      
  4.     def __init__(self,nome,quantita,posizione):
  5.        
  6.         self.nome=nome
  7.         self.quantita=quantita
  8.         self.posizione=posizione
  9.         Oggetto.Pz +=1        
  10.        
  11.     def Info(self):
  12.         return f'nome:{self.nome} \n quantità: {self.quantita}\n sito in {self.posizione}'
  13.      
  14. og1=Oggetto('lima',2,'armadio1')
  15. og2=Oggetto('martello',1,'cassetto')
  16. og3=Oggetto ('torcia',2,'cassetto')
  17. og4=Oggetto('cacciaviti',7,'cassetto')
  18.  
  19. print(Oggetto.Info(og1))
  20. print(og2.Info())
  21. print(Oggetto.Info(og3))
  22. print(og4.Info())
  23. print('Pezzi catalogati:',Oggetto.Pz)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement