LoyaltyScheme.cpp
上传用户:sz0451
上传日期:2022-07-29
资源大小:256k
文件大小:1k
源码类别:

.net编程

开发平台:

Visual C++

  1. #include "stdafx.h" 
  2. #include "LoyaltyScheme.h"
  3. #using <mscorlib.dll>
  4. using namespace System; 
  5. LoyaltyScheme::LoyaltyScheme()
  6. {
  7.     Console::WriteLine("Congratulations, you now qualify for bonus points");
  8.     totalPoints = 0;
  9. }
  10. LoyaltyScheme::~LoyaltyScheme(void)
  11. {
  12.     Console::WriteLine("Loyalty scheme now closed");
  13. }
  14. void LoyaltyScheme::EarnPointsOnAmount(double amountSpent)
  15. {
  16. int points = (int)(amountSpent / 10);
  17. totalPoints += points;
  18. Console::Write("New bonus points earned: ");
  19. Console::WriteLine(points);
  20. }
  21. void LoyaltyScheme::RedeemPoints(int points)
  22. {
  23. if (points <= totalPoints)
  24. {
  25. totalPoints -= points;
  26. }
  27. else 
  28. {
  29. totalPoints = 0;
  30. }
  31. }
  32. int LoyaltyScheme::GetPoints()
  33. {
  34. return totalPoints;
  35. }