I don't speak French so I'm struggling a bit with the variable
names, however...

"Marco Rompré" <marcodrom...@gmail.com> wrote in message

class CompteBancaire:
   def __init__(self,nom,solde,interet):       #Nous allons instancier et
       self.nom, self.solde, self.interet = nom,solde,interet

   def depot(self,somme=0):                    #Méthode pour additionner
       self.solde=self.solde+somme

def retrait(self,somme=0): #Méthode pour soustraire les
       if self.nom == 'Sandon':
           if self.solde-somme<0:
print "Les fonds sont insuffisants. Essayez un autre montant
           else:
               self.solde=self.solde-somme
       elif self.nom =='Étudiant':             #Vérifie s'il s'agit d'un
           if self.solde - somme < -self.margeCre:      # Vérifie si le
               print "Désolé, votre retrait dépasse la marge de crédit
           else:                               # sinon déuit le montant
               self.margeCre = self.solde - somme
               self.solde = 0

   def calculInteret(self,calculInteret=0):     #Méthode qui calcule les
       self.interet=self.solde*calculInteret/100
       self.solde=(self.solde*calculInteret/100)+self.solde

   def affiche_solde(self):                    #Méthode qui affiche le
       print "Le solde du compte bancaire de %s est de %d $CAD"
%(self.nom,self.solde)
       print "Vous avez récolté %d $CDN en intérêt"%(self.interet)

class CompteEtudiant(CompteBancaire):
   "définition du compte bancaire pour étudiant dérivé du compte bancaire
   def __init__(self, nom='', solde=0, margeCre=0):
       CompteBancaire.__init__(self, nom='Nom', solde=0, interet=0)
       self.nom, self.solde, self.margeCre = nom, solde, margeCre

   def affiche_solde(self, somme=0):           #Méthode constructeur qui
       print "%s--Votre solde bancaire est de %d $CAD"
%(self.nom,self.solde)
       print "Le solde de votre marge de crédit est de %d $CAD"
%(self.margeCre)

This second class does not seem to override any of the original
methods so does not modify the balance based on the "overdraft2 value.
This the status method prints out the balance based on a simple
calculation without taking the overdraft into account.

If you want to change that I think you will need to add override versions
of the withdrawal method to your subclass.

But I admit my understanding of the code is not deep, I didn't spend
enough time deciphering it for that...

Alan G.






When I run it,  it gives me this:


Les fonds sont insuffisants. Essayez un autre montant pour votre retrait!
(Try to witthdraw 1200 with a balance of 880$) This is good!
Le solde du compte bancaire de Sandon est de 880 $CAD (This is fine too)
Vous avez récolté 80 $CDN en intérêt (This too)
Étudiant--Votre solde bancaire est de 0 $CAD (Trying to withdraw 1100$ with
a cash balance of 800 plus a credit line of 1000$)
Le solde de votre marge de crédit est de -300 $CAD (It would be supposed to
say that my credit line balance is 700= 1000-300 knowing that this 300 was
the amount missing from mu cash balance)


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to