Attachment 'aliments.py'

Download

   1 class Fruit:
   2     def __init__(self, poids=1):
   3         """
   4         Constructeur.
   5         """
   6         self.__poids = poids
   7 
   8     def __repr__(self):
   9         """
  10         Representation en str.
  11         """
  12         return "Un fruit de %s kilos."%self.poids()
  13 
  14     def poids(self):
  15         """
  16         Retourne le poids.
  17         """
  18         return self.__poids
  19 
  20     def est_un_fruit(self):
  21         """
  22         Retourne True si c'est un fruit.
  23         """
  24         return True
  25 
  26 class Banane(Fruit):
  27     def __repr__(self):
  28         """
  29         Representation en str.
  30         """
  31         return "Une banane de %s kilos."%self._poids
  32 
  33 class Fraise(Fruit):
  34     def __repr__(self):
  35         """
  36         Representation en str.
  37         """
  38         return "Une fraise de %s kilos."%self._poids
  39 
  40     def __add__(self, autre):
  41         """
  42         Fusion de la fraise avec une autre fraise.
  43         """
  44         return Fraise(self.poids()**2 + autre.poids()**2)
  45 
  46 class Ananas(Fruit):
  47     def __repr__(self):
  48         """
  49         Representation en str.
  50         """
  51         return "Un ananas de %s kilos."%self._poids

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-07-16 16:06:52, 22.2 KB) [[attachment:Huard_cythone.sws]]
  • [get | view] (2009-07-16 13:22:53, 1.1 KB) [[attachment:aliments.py]]
  • [get | view] (2009-08-04 17:54:10, 6.1 KB) [[attachment:devoir.tex]]
  • [get | view] (2009-07-16 13:24:14, 2.2 KB) [[attachment:makecmds.sty]]
  • [get | view] (2009-07-16 13:24:05, 0.3 KB) [[attachment:makefile]]
  • [get | view] (2009-07-16 13:24:23, 3.9 KB) [[attachment:sagetex.py]]
  • [get | view] (2009-07-16 13:24:28, 4.8 KB) [[attachment:sagetex.sty]]
  • [get | view] (2009-07-16 13:31:00, 235.8 KB) [[attachment:sagetexpackage.pdf]]
  • [get | view] (2009-07-16 13:23:09, 0.3 KB) [[attachment:sequence.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.