Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Exo1
  8. {
  9. public class Compte
  10. {
  11. private static int numAuto = 0;
  12. private static String MONNAIE = "euro(s)";
  13. private int numCpt;
  14. private double solde;
  15.  
  16. public Compte(double solde)
  17. {
  18. this.solde = solde;
  19. NumAuto++;
  20. this.numCpt = NumAuto;
  21. }
  22.  
  23. public Compte() : this(0)
  24. {
  25. }
  26.  
  27. public double Solde
  28. {
  29. get
  30. {
  31. return this.solde;
  32. }
  33.  
  34. private set
  35. {
  36. this.solde = value;
  37. }
  38. }
  39.  
  40. public int NumCpt
  41. {
  42. get
  43. {
  44. return this.numCpt;
  45. }
  46.  
  47. private set
  48. {
  49. this.NumCpt = value;
  50. }
  51. }
  52.  
  53. public static int NumAuto
  54. {
  55. get
  56. {
  57. return numAuto;
  58. }
  59.  
  60. private set
  61. {
  62. numAuto = value;
  63. }
  64. }
  65.  
  66. public void Crediter(double montant)
  67. {
  68. this.Solde += montant;
  69. }
  70.  
  71. public void Debiter(double montant)
  72. {
  73. this.Solde -= montant;
  74. }
  75.  
  76. public override string ToString()
  77. {
  78. return "-----\n Compte numero: " + this.NumCpt + "\n Solde : " + this.Solde + " " + MONNAIE+"\n-----";
  79. }
  80.  
  81. public override bool Equals(object obj)
  82. {
  83. return obj is Compte compte &&
  84. this.NumCpt == compte.NumCpt;
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement