Advertisement
wis3_guy

Customer Class

Feb 13th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace applicationName
  7. {
  8. public class Customer
  9. {
  10. // Members
  11. private int id;
  12. private string name;
  13. //private string lName;
  14. private string address;
  15. // private string regionID;
  16. private string email;
  17. private double phone;
  18. private DateTime addDate;
  19. private int totalTransactions;
  20.  
  21. // Constructors
  22. public Customer()
  23. {
  24. id = 159256;
  25. name = "Jimmy Dean";
  26. address = "117 Road Lane";
  27. // regionID = "SW";
  28. email = "jim@gmail.com";
  29. phone = 2053335555;
  30. addDate = DateTime.Today;
  31. totalTransactions = 200;
  32. }
  33.  
  34. public Customer(int newId, string newName, string newAddress, string newEmail, double newPhone, DateTime newDate, int newTotalTransactions)
  35. {
  36. id = newId;
  37. name = newName;
  38. address = newAddress;
  39. //regionID = newregionID;
  40. email = newEmail;
  41. phone = newPhone;
  42. addDate = newDate;
  43. totalTransactions = newTotalTransactions;
  44. }
  45.  
  46. //Properties
  47. public int Id
  48. {
  49. get { return id; }
  50. set { id = value; }
  51. }
  52.  
  53. public string Name
  54. {
  55. get { return name; }
  56. set { name = value; }
  57. }
  58.  
  59. public string Address
  60. {
  61. get { return address; }
  62. set { address = value; }
  63. }
  64.  
  65. public string Email
  66. {
  67. get { return email; }
  68. set { email = value; }
  69. }
  70.  
  71. public double Phone
  72. {
  73. get { return phone; }
  74. set { phone = value; }
  75. }
  76.  
  77. public DateTime AddDate
  78. {
  79. get { return addDate; }
  80. set { addDate = value; }
  81. }
  82.  
  83. public int TotalTransactions
  84. {
  85. get { return totalTransactions; }
  86. set { totalTransactions = value; }
  87. }
  88.  
  89. //Work Methods
  90.  
  91. public int CalcTransaction()
  92. {
  93. //Get current date
  94. DateTime currDate = DateTime.Now;
  95.  
  96. //Get difference in months
  97. int months = currDate.Month - addDate.Month;
  98.  
  99. //Get average transactions per month
  100. int avgTransactions = 0;
  101. if (months > 0) //If statement insures it doesn't divide by 0
  102. avgTransactions = totalTransactions / months;
  103.  
  104. //Calculate discount
  105. int baseline = 3;
  106. int low = 6;
  107. int high = 15;
  108. int discount = 0;
  109.  
  110. if (avgTransactions <= baseline)
  111. discount = 0;
  112.  
  113. if (avgTransactions > low) //If has an average of 8 or more transactions per month, awarded 5% discount
  114. discount = 5;
  115.  
  116. if (avgTransactions > high) //If has a an average of 15 or more transactions per month, awarded 10% discount
  117. discount = 10;
  118.  
  119. return discount;
  120.  
  121. //
  122.  
  123. }
  124.  
  125.  
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement