bank.bao
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# bank.bao — système bancaire
classe Compte:
fonction nouveau(titulaire, solde):
ce.titulaire = titulaire
ce.solde = solde
fonction deposer(montant):
si montant <= 0:
afficher("Montant invalide")
retourner faux
ce.solde = ce.solde + montant
afficher("Dépôt: +" + texte(montant) + " → " + texte(ce.solde))
retourner vrai
fonction retirer(montant):
si montant > ce.solde:
afficher("Solde insuffisant")
retourner faux
ce.solde = ce.solde - montant
afficher("Retrait: -" + texte(montant) + " → " + texte(ce.solde))
retourner vrai
fonction transferer(autre, montant):
si ce.retirer(montant):
autre.deposer(montant)
afficher("Transfert " + ce.titulaire + " → " + autre.titulaire + ": " + texte(montant))
afficher("🏦 Banque Baobab")
amina = nouveau Compte("Amina", 500)
kofi = nouveau Compte("Kofi", 0)
afficher("Compte Amina: " + texte(amina.solde))
amina.deposer(250)
amina.retirer(100)
amina.transferer(kofi, 200)
afficher("Compte Amina: " + texte(amina.solde))
afficher("Compte Kofi: " + texte(kofi.solde))
Baobab Studio Terminal v1.0.0 — type 'help' for commands