Advertisement
wis3_guy

Customer Group Class

Feb 11th, 2013
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace programName
  7. {
  8. public class CustomerGroup
  9. {
  10. //Members
  11. private int groupID;
  12. private string customerName;
  13. private string address;
  14. private DateTime registerDate;
  15. private int totalTransactions;
  16. private Employee accountExecutive = new Employee();
  17. private List<CustomerGroup> customer = new List<CustomerGroup>();
  18.  
  19. private List<CustomerGroup> customer;
  20.  
  21.  
  22.  
  23. public CustomerGroup()
  24. {
  25. //Constructors
  26. groupID = 0;
  27. customerName = "";
  28. address = "";
  29. registerDate = DateTime.Now;
  30. totalTransactions = 200;
  31. accountExecutive = new Employee();
  32. List<Customer> unsortedCustomer = new List<Customer>();
  33. }
  34.  
  35.  
  36. public CustomerGroup (int newgroupID, string newCustomerName, string newAddress, DateTime newRegisterDate, int newTotalTransactions, Employee newaccountExecutive, List<Customer>newUnsortedCustomer)
  37. {
  38. groupID = newgroupID;
  39. customerName = newCustomerName;
  40. address = newAddress;
  41. registerDate = newRegisterDate;
  42. totalTransactions = newTotalTransactions;
  43. accountExecutive = newaccountExecutive;
  44. unsortedCustomer=newUnsortedCustomer;
  45. }
  46.  
  47. public int groupID
  48. {
  49. get { return groupID; }
  50. set { groupID = value; }
  51. }
  52.  
  53. public string customerName
  54. {
  55. get { return customerName; }
  56. set { customerName = value; }
  57. }
  58.  
  59. public string address
  60. {
  61. get { return address; }
  62. set { address = value; }
  63. }
  64.  
  65. public DateTime registerDate
  66. {
  67. get { return registerDate; }
  68. set { registerDate = value; }
  69. }
  70.  
  71. public int totalTransactions
  72. {
  73. get { return totalTransactions; }
  74. set { totalTransactions = value; }
  75. }
  76.  
  77. public Employee accountExecutive
  78. {
  79. get { return accountExecutive; }
  80. set { accountExecutive = value; }
  81. }
  82.  
  83. public List<CustomerGroup> customer
  84. {
  85. get { return customer; }
  86. set { customer = value; }
  87. }
  88.  
  89. //Work Methods
  90.  
  91. //logic for determining discounts
  92. public int CalcRegisterDate()
  93. {
  94. //Get current date
  95. DateTime currDate = DateTime.Now;
  96.  
  97. //Get difference in months
  98. int months = currDate.Month - addDate.Month;
  99.  
  100. //Get average transactions per month
  101. int avgTransactions = 0;
  102. if (months > 0) //If statement insures it doesn't divide by 0
  103. avgTransactions = totalTransactions / months;
  104.  
  105. //Calculate discount
  106. int low = 6;
  107. int high = 15;
  108. int discount = 0;
  109.  
  110. if (avgTransactions > low) //If has an average of 8 or more transactions per month, awarded 5% discount
  111. discount = 5;
  112.  
  113. if (avgTransactions > high) //If has a an average of 15 or more transactions per month, awarded 10% discount
  114. discount = 10;
  115.  
  116. return discount;
  117.  
  118.  
  119. public int GetRegisterDate()
  120. {
  121. // Get today's date
  122. DateTime currDate = DateTime.Now;
  123.  
  124. // Get the difference in years
  125. int years = currDate.Year - startDate.Year;
  126.  
  127. // Subtract another year if we're before the
  128. // start date in the current year
  129. if (currDate.Month < startDate.Month || (currDate.Month == startDate.Month && currDate.Day < startDate.Day))
  130. years--;
  131.  
  132. return years;
  133.  
  134. }
  135.  
  136.  
  137.  
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement