public float Retrait(float montant) { if (montant <= this.Solde) { Transaction1 tr1bis = new Transaction1 { Montant = montant, Date = DateTime.Now }; //this.ListeTransactions[this.NombreTransaction] = tr1bis; this.NombreTransaction++; this.ListeTransactions1.Add(tr1bis); this.Solde -= montant; return(this.Solde); } else { throw new Exception("Transaction impossible"); } }
public float Depot(float montant) { /* Méthode 1 * Transaction tr = new Transaction(montant, DateTime.Now); * * Méthode 2 * Transaction1 tr1 = new Transaction1(); * tr1.Montant = montant; * tr1.Date = DateTime.Now; * * Méthode 3 */ Transaction1 tr1bis = new Transaction1 { Montant = montant, Date = DateTime.Now }; //this.ListeTransactions[this.NombreTransaction] = tr1bis; this.NombreTransaction++; this.ListeTransactions1.Add(tr1bis); this.Solde += montant; return(this.Solde); }