Exercice 4: Simulateur de Bourse
class ActionBoursiere {
public string Nom { get; set; }
public double Prix { get; set; }
public void MettreAJourPrix() {
Prix += new Random().NextDouble() * 10 - 5;
}
}
class Portefeuille {
public Dictionary Actions = new Dictionary();
public double Acheter(string nom, int quantite, double prix) {
if (!Actions.ContainsKey(nom)) Actions[nom] = 0;
Actions[nom] += quantite;
return prix * quantite;
}
}
Pas encore de commentaires.
Ajouter un commentaire
Veuillez vous connecter pour ajouter un commentaire.