Hi im doin a programmin course at university and in one on my exercise i
have to do that<div><br></div><div>I had to define<span style="font-family: Verdana,sans-serif; font-size: 13px;"> a class
CompteBancaire(CompteBancaire is bankaccount in french), that would
allow me to create objects Compte1, Compte2,etc.</span></div>
<span style="font-family: Verdana,sans-serif; font-size: 13px;"></span><span style="font-family: Verdana,sans-serif; font-size: 13px;"><br><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">
The following methods need to be defined </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;"> -
depot(somme) would allow me to add cash to my account balance</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">
- retrait(somme) would allow me to withdraw some cash from
my account</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;"> - ajouterInterest() would allow me to
add interest</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">
- affiche() would allow me to display the account
owner and his account balance</div><br><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">
the retrait(somme) method is not supposed to let the account balance
being negative.</div><br><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;"><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">
</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">3.2</div><br><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">Create a sub-class to CompteBancaire and name it
CompteEtudiant. Each</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">CompteEtudiant
(student account) should have a $1000CAD credit line. Write a builder
or constructor for this new class. Surcharge the retrait(somme) method
to make sure that the student can withdraw to their limit.</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">Test
the class<br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;"><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">
Here's my code for now this is 3.1and 3.2 in the same code</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;"><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">Please
help me i think im on the right track but i need some guidance in the
dark. lol</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;"><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">Thank
you tutors</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">
<br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;"><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit;">#Exercice 3,2 - Gestion d'un compte bancaire pour étudiant avec marge de crédit disponible de 1000$CDN<br>
<br>class CompteBancaire:<br> "définition d'un compte bancaire"<br> <br> def __init__(self,nom,solde,interet): #Nous allons instancier et initialiser les objets à la classe<br> self.nom, self.solde, self.interet = nom,solde,interet<br>
<br> def depot(self,somme=0): #Méthode pour additionner les dépôts au compte<br> self.solde=self.solde+somme <br><br> def retrait(self,somme=0): #Méthode pour soustraire les retraits au compte<br>
if self.nom == 'Sandon':<br> if self.solde-somme<0:<br> print "Les fonds sont insuffisants. Essayez un autre montant pour votre retrait!"<br> else:<br> self.solde=self.solde-somme<br>
<br> elif self.nom =='Étudiant': #Vérifie s'il s'agit d'un compte étudiant<br> if self.solde - somme < -self.margeCre: # Vérifie si le retrait dépasse la marge de crédit maximum<br>
print "Désolé, votre retrait dépasse la marge de crédit autorisé"<br> else: # sinon déuit le montant retirer de la marge de crédit<br> self.margeCre = self.solde - somme<br>
self.solde = 0<br> <br> def calculInteret(self,calculInteret=0): #Méthode qui calcule les intérêts et le solde résiduel<br> self.interet=self.solde*calculInteret/100<br> self.solde=(self.solde*calculInteret/100)+self.solde<br>
<br> def affiche_solde(self): #Méthode qui affiche le solde et le montant d'intérêt accumulé<br> print "Le solde du compte bancaire de %s est de %d $CAD" %(self.nom,self.solde)<br>
print "Vous avez récolté %d $CDN en intérêt"%(self.interet)<br>#<br>###################### <br># création de la gestion d'un compte étudiant autorisant une marge de crédit de (1 000$)<br><br>class CompteEtudiant(CompteBancaire):<br>
"définition du compte bancaire pour étudiant dérivé du compte bancaire standard"<br> def __init__(self, nom='', solde=0, margeCre=0):<br> CompteBancaire.__init__(self, nom='Nom', solde=0, interet=0)<br>
self.nom, self.solde, self.margeCre = nom, solde, margeCre<br> <br> def affiche_solde(self, somme=0): #Méthode constructeur qui redéfini la fonction affiche_solde pour le compte étudiant<br> print "%s--Votre solde bancaire est de %d $CAD" %(self.nom,self.solde)<br>
print "Le solde de votre marge de crédit est de %d $CAD" %(self.margeCre)<br> <br>##############################################################<br>#jeux d'essai avec des valeurs fictives<br>if __name__=='__main__': #Référence au corps principal du programme.<br>
compte1 = CompteBancaire('Sandon',800,0) #Essai avec un solde de 800$, un retrait de 1200$ et des intérêts de 10%<br> compte1.depot(0)<br> compte1.retrait(1200)<br> compte1.calculInteret(10)<br> compte1.affiche_solde()<br>
compte2 = CompteEtudiant('Étudiant',800,1000)<br> compte2.retrait(1100)<br> compte2.affiche_solde()<br>############################################################<br></div></span><br><br><div class="gmail_quote">
On Wed, Mar 31, 2010 at 4:39 PM, Lie Ryan <span dir="ltr"><<a href="mailto:lie.1296@gmail.com">lie.1296@gmail.com</a>></span> wrote:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 04/01/2010 12:35 AM, Marco Rompré wrote:<br>
> what's wrong in this code??? if I want it to do what i describe in my<br>
> message.<br>
<br>
</div>What happens when you run it? You did not even write that in your<br>
message. And please reply-all to the list.<br></blockquote><div><br>When I run it, it gives me this:<br></div></div><br>>>> <br>Les fonds sont insuffisants. Essayez un autre montant pour votre retrait! (Try to witthdraw 1200 with a balance of 880$) This is good! <br>
Le solde du compte bancaire de Sandon est de 880 $CAD (This is fine too)<br>Vous avez récolté 80 $CDN en intérêt (This too)<br>Étudiant--Votre solde bancaire est de 0 $CAD (Trying to withdraw 1100$ with a cash balance of 800 plus a credit line of 1000$)<br>
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)<br><br>Would you please help me???<br clear="all">
<br>Ocram the newbie<br><br>