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 class="Apple-style-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>
<div><span class="Apple-style-span" style="font-family: Verdana, sans-serif; font-size: 13px; "></span><span class="Apple-style-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; "><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
#Exercice 3,1 - Gestion d'un compte bancaire</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">class CompteBancaire:</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> "définition d'un compte bancaire"</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
def __init__(self,nom,solde,interet): #Nous allons instancier et initialiser les objets à la classe</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> self.nom, self.solde, self.interet = nom,solde,interet</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> def depot(self,somme=0): #Définition des fonctions</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> self.solde=self.solde+somme #Pour additionner les dépôts au compte</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
<br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> def retrait(self,somme=0): #Pour soustraire les dépôts au compte</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
if self.solde-somme<0:</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> print "Les fonds sont insuffisants. Essayez un autre montant pour votre retrait!"</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
else:</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> self.solde=self.solde-somme</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
def calculInteret(self,calculInteret=0): #Calcul des intérêts et du solde résiduel</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> self.interet=self.solde*calculInteret/100</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> self.solde=(self.solde*calculInteret/100)+self.solde</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
def affiche_solde(self):</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> print "Le solde du compte bancaire de %s est de %d $CAD" %(self.nom,self.solde)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
print "Vous avez récolté %d $CDN en intérêt"%(self.interet)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">#</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
###################### </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "># création de la gestion d'un compte étudiant autorisant une marge de crédit de (1 000$)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
<br></div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">class CompteEtudiant(CompteBancaire):</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> "définition du compte bancaire pour étudiant dérivé du compte bancaire standard"</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> def __init__(self, nom='Étudiant', solde=200, margeCre = 1000): #Limite de marge de crédit fixé à 1 000$</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
CompteBancaire.__init__(self, nom='Sandon', solde=800, interet=0)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> self.nom, self.solde, self.margeCre = nom, solde, margeCre</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> def margeCre (self, somme=0):</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
if somme-self.solde>margeCre:</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> print "Désolé vous dépassez la marge de crédit autorisé"</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
else:</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> self.solde = (self.solde-somme)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> margeCre=margeCre+self.solde</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
def affiche_solde(self, somme=0):</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> print "Le solde du compte bancaire de %s est de %d $CAD" %(self.nom,self.solde)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
print "Le solde de votre marge de crédit est de %d $CAD" %(self.margeCre)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> print "Vous avez récolté %d $CDN en intérêt"%(self.interet)</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> </div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">##############################################################</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">#jeux d'essai avec des valeurs fictives</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">if __name__=='__main__': #Référence au corps principal du programme.</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> compte1 = CompteBancaire('Sandon',800,0)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> compte1.depot(0)</div>
<div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> compte1.retrait(1200)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> compte1.calculInteret(10)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
compte1.affiche_solde()</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> compte2 = CompteEtudiant('Étudiant', 800)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">
compte2.retrait(900)</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; "> compte2.affiche_solde()</div><div style="margin-top: 0px; margin-bottom: 0px; direction: inherit; ">##################################</div>
<div><br></div></div><div><br></div></span><br>-- <br>Ocram the newbie
</div>