Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. // CarWarhouse.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <string>
  6. #include <iostream>
  7.  
  8. #include "agents.h"
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. string agentName;
  15. int agentID;
  16.  
  17. agents A_1;
  18.  
  19. cout << "Administrative login: ";
  20. cin >> agentName;
  21. A_1.setAgentName(agentName);
  22. cout << "Administrative password: ";
  23. cin >> agentID;
  24.  
  25. while (agentID != A_1.getAgentID())
  26. {
  27. cout << "Invalid loginn";
  28.  
  29. cout << "nAdministrative password: ";
  30. cin >> agentID;
  31. }
  32.  
  33. cout << endl << "Welcome back, Agent " << endl;
  34.  
  35. cout << "Active Agents: " << endl;
  36.  
  37. A_1.agentIdentities(); //Function call to agents.cpp
  38.  
  39. }
  40.  
  41. agents.cpp
  42.  
  43. #include "pch.h"
  44. #include "agents.h"
  45. #include <string>
  46.  
  47. agents::agents() {
  48. agentName = "";
  49. agentID = 1111;
  50. int const size = 4;
  51. string agentMembers[size] = { "Jacob", "Nathan", "Tomas", "Jack" }; //Agent members string array I want to print to screen.
  52. }
  53.  
  54. agents::agents(string name, int ID)
  55. {
  56. agentName = name;
  57. agentID = ID;
  58. }
  59.  
  60. agents::~agents()
  61. {}
  62.  
  63.  
  64. string agents::getAgentName() const
  65. {
  66. return agentName;
  67. }
  68.  
  69. int agents::getAgentID() const
  70. {
  71. return agentID;
  72. }
  73.  
  74. void agents::setAgentName(string incoming)
  75. {
  76. agentName = incoming;
  77. }
  78.  
  79. void agents::setAgentIdentity(int ID)
  80. {
  81. agentID = ID;
  82. }
  83.  
  84. void agents::agentIdentities() //Main calls this function.
  85. {
  86. for (int i = 0; i < size; i++)
  87. {
  88. cout << agentMembers[i] << endl;
  89. }
  90.  
  91. cout << agentMembers[0];
  92. }
  93.  
  94.  
  95. #pragma once
  96.  
  97. #include <iostream>
  98. #include <string>
  99.  
  100. using namespace std;
  101.  
  102. #ifndef agents_h
  103. #define agents_h
  104.  
  105. class agents{
  106.  
  107. public:
  108. //First thing, default constructor
  109. agents();
  110.  
  111. //Overload Constructor
  112. agents(string, int);
  113.  
  114. //Destructor
  115.  
  116. ~agents();
  117.  
  118. //Accessor Functions
  119.  
  120. //If accessor doesn't modify member variables, end with const on the function name.
  121.  
  122. string getAgentName() const;
  123. //getName returns name of the customer.
  124.  
  125. int getAgentID() const;
  126.  
  127.  
  128. void setAgentName(string);
  129. //getName returns the newly assigned customer reference number.
  130.  
  131. void setAgentIdentity(int);
  132.  
  133. void agentIdentities();
  134. //Retrieves agent identites (names within the string array).
  135.  
  136. private:
  137. //Member variables
  138. string agentName;
  139. int agentID;
  140. string agentMembers[4];
  141. int size = 4;
  142. };
  143.  
  144. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement