Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5. #include <time.h>
  6.  
  7. #include "Customer.h"
  8. #include "Campaign.h"
  9. #include "Ad.h"
  10. #include "AdServingEngine.h"
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16. AdServingEngine ase;
  17. while (true)
  18. {
  19. int selection;
  20. cout << "1. Create customer.\n2. Create Campaign.\n3. Create Ad.\n4. Get next ad.\n5. Exit.\n";
  21. cin >> selection;
  22.  
  23. string newCustomerName, newCampaignName, newAdName, newAdText;
  24. float newCampaignCost;
  25. int newAdType;
  26.  
  27. string customerName, campaignName;
  28. string campaignOwner, adOwner;
  29. int fromYear, fromMonth, fromDay, toYear, toMonth, toDay;
  30. struct tm fromDate, toDate;
  31.  
  32. vector<Customer> listOfCustomers;
  33. vector<Campaign> listOfCampaigns;
  34.  
  35. int menuPosition = 1;
  36. int givenMenuPosition;
  37.  
  38. switch (selection)
  39. {
  40. case 1:
  41. cout << "Enter customer name: ";
  42. cin >> newCustomerName;
  43. ase.AddCustomer(newCustomerName);
  44. break;
  45. case 2:
  46. cout << "Enter for which customer: ";
  47. cin >> campaignOwner;
  48. Customer* cust;
  49. cust = ase.GetCustomer(campaignOwner);
  50. if (cust)
  51. {
  52. cout << "Enter the campaign name: ";
  53. cin >> newCampaignName;
  54.  
  55. cout << "Enter the start year YYYY: ";
  56. cin >> fromYear;
  57. cout << "Enter the start month MM: ";
  58. cin >> fromMonth;
  59. cout << "Enter the start day DD: ";
  60. cin >> fromDay;
  61. fromDate.tm_year = fromYear - 1900;
  62. fromDate.tm_mon = fromMonth + 1;
  63. fromDate.tm_mday = fromDay;
  64. fromDate.tm_hour = 0;
  65. fromDate.tm_min = 0;
  66. time_t from = mktime(&fromDate);
  67.  
  68. cout << "Enter the end year YYYY: ";
  69. cin >> toYear;
  70. cout << "Enter the end month MM: ";
  71. cin >> toMonth;
  72. cout << "Enter the end day DD: ";
  73. cin >> toDay;
  74. toDate.tm_year = toYear - 1900;
  75. toDate.tm_mon = toMonth + 1;
  76. toDate.tm_mday = toDay;
  77. toDate.tm_hour = 0;
  78. toDate.tm_min = 0;
  79. time_t to = mktime(&toDate);
  80.  
  81. cout << "Enter the campaign cost: ";
  82. cin >> newCampaignCost;
  83.  
  84. cust->AddCampaign(newCampaignName, from, to, newCampaignCost);
  85. }
  86. else
  87. {
  88. cout << "Customer not found." << endl;
  89. }
  90. break;
  91. case 3:
  92. cout << "Enter for which customer: ";
  93. cin >> campaignOwner;
  94. Customer* cust2;
  95. cust2 = ase.GetCustomer(campaignOwner);
  96. if (cust2)
  97. {
  98. listOfCampaigns = cust2->GetCampaignList();
  99. for (auto cam : listOfCampaigns)
  100. {
  101. campaignName = cam.GetCampaignName();
  102.  
  103. cout << menuPosition << ". " << campaignName << endl;
  104. menuPosition++;
  105. }
  106. cout << "Enter for which campaign: ";
  107. cin >> givenMenuPosition;
  108. givenMenuPosition = givenMenuPosition -1;
  109. Campaign* cam;
  110. cam = cust2->GetCampaign(givenMenuPosition);
  111. cout << "Enter ad name: ";
  112. cin >> newAdName;
  113. cout << "Enter ad text: ";
  114. cin >> newAdText;
  115. cout << "1.Scroll, 2.Blink, 3.PlainText: ";
  116. cin >> newAdType;
  117.  
  118. cam->AddAd(newAdName, newAdText, newAdType);
  119. }
  120. else
  121. {
  122. cout << "Customer not found." << endl;
  123. }
  124. continue;
  125. //case 4:
  126. // ad = ase.GetNextAd();
  127. // cout << ad;
  128. case 5:
  129. return 0;
  130. case 6:
  131. listOfCustomers = ase.GetListOfCustomer();
  132. for (auto cust : listOfCustomers)
  133. {
  134. customerName = cust.GetCustomerName();
  135. cout << customerName << endl;
  136. }
  137. default:
  138. cout << "Wrong format!" << endl;
  139. break;
  140. }
  141. }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement