Menu

[Solved]Gatecontrolhpp Pragma Include Iostream Include String Include Utility Include Vector Using Q37169019

// GateControl.hpp //

#pragma once

#include iostream

#include string

#include utility

#include vector

using namespace std;

typedef uint32_t CardNumber;

typedef uint32_t GateNumber;

struct Authorization

{

Authorization() {}

Authorization(CardNumber number, const string& name, conststring& startTime, const string& endTime):number_(number),name_(name), startTime_(startTime), endTime_(endTime) {}

CardNumber number_;

string name_;

string startTime_;

string endTime_;

};

typedef map AuthorizationMap;

typedef AuthorizationMap::iterator AuthorizationIterator;

typedef AuthorizationVector;

struct Transaction

{

Transaction() {}

Transaction(CardNumber number, const string& name, conststring& date, const string& time, boolaccessAllowed):number_(number), name_(name), date_(date),time_(time), accessAllowed_(accessAllowed) {}

CardNumber number_;

string name_;

string date_;

string time_;

bool accessAllowed_;

};

typedef TransactionVector;

class GateControl

{

public:

bool AccessAllowed(CardNumber number);

bool AddAuthorization(CardNumber number, const string& name,const string& startTime, const string& endTime);

bool ChangeAuthorization(CardNumber number, const string&name, const string& startTime, const string& endTime);

bool DeleteAuthorization(CardNumber number);

void GetAllAuthorizations(AuthorizationVector&authorizationVector);

void GetAllTransactions(TransactionVector&transactionVector);

bool GetCardAuthorization(CardNumber number, Authorization&authorization);

bool GetCardTransaction(CardNumber number,TransactionVector& transactionVector);

private:

AuthorizationMap authorizationMap_;

TransactionVector trasnactionVector_;

};

—————————————————————————————————————————————

// GateControl.cpp //

#include iostream

#include string

#include utility

#include vector

#include “GateControl.hpp”

using namespace std;

extern string gCurrentDate;

extern string gCurrentTime;

bool AccessAllowed(CardNumber number) {

bool isAllowed = false;

string name = “* * *”;

AuthorizationIterator position;

position = authorizationMap_.find(number);

if(position == authorizationMap_.end()) {

isAllowed = false;

} else if((position != authorizationMap_.end()) &&(position->second.startTime_ <= gCurrentTime) &&(gCurrentTime <= position->second.endTime_)) {

name = position->second.name_;

isAllowed = true;

}

Transaction transaction(number, name, gCurrentDate,gCurrentTime, isAllowed);

transactionVector_.push_back(transaction);

return isAllowed;

}

bool AddAuthorization(CardNumber number, const string& name,const string& startTime, const string& endTime) {

bool isCredible = false;

Authorization new_credentials(number, name, startTime,endTime);

if(authorizationMap_.find(number) == authorizationMap_.end()){

authorizationMap_.insert(make_pair(number,new_credentials());

isCredible = true;

} else if(authorizationMap_.find(number) !=authorizationMap_.end()) {

isCredible = false;

}

return isCredible;

}

bool ChangeAuthorization(CardNumber number, const string&name, const string& startTime, const string& endtTime){

// arguments are card number, cardholder name, and time range.changes the name and time range of each existing card. returns aboolean value. false means the card was not found and could not bechanged. true means change was successful. //

// FUNCTION BODY HERE. Please help. //

}

bool DeleteAuthorization(CardNumber number) {

// argument is a card number. it returns a boolean value. falsemeans the card was not there and could not be deleted. true meanssuccessful delete. //
// FUNCTION BODY HERE. Please help. //

}

void GetAllAuthorizations(AuthorizationVector&authorizationVector) {

AuthorizationIterator iterator;

// has one argument. address of the vector to receive all of theauthorization records. the vector will be cleared if there are noauthorization records. //

// FUNCTION BODY HERE. Please help. //

}

void GetAllTransactions(TransactionVector&transactionVector) {

// has one argument. address of vector to receive alltransaction records.

// FUNCTION BODY HERE. Please help. //

}

bool GetCardAuthorization(CardNumber number, Authorization&authorization) {

bool cardAuthorization = false;

AuthorizationIterator index;

index = authorizationMap_.find(number);

if(index == authorizationMap_.end()) {

cardAuthorization = false;

} else {

authorization = index->second;

cardAuthorization = true;

}

return cardAuthorization;

}

bool GetCardTransactions(CardNumber number,TransactionVector& transactionVector) {

// input argument is the card number. output argument is theaddress of a vector to receive the transaction records for thespecific card. if there are no transactions, vector will becleared. it returns a boolean value. false means the card was notfound and no transactions could be found. true means success.//

// FUNCTION BODY HERE. Please help. //

}

Here is the project I am working on right now. If someone couldhelp me with these 8 functions that would be great. And maybe asingle comment line, so I can better understand how you obtainedthe solution that would be awesome. Thank you for your help!

UPDATE: I apologize for the lack of information regarding theproblem. It is a software to control access of a company’sfacility. There are several buildings that are protected by anelectric gate. Employees use an authorized card to gain access tothe facility. The gate has a card reader that is connectedto a computer that will receive a card’s identifying number,validate the access, and operate the gate operator’s motor to openthe gate. The computer will record each transaction—the date andtime of each access, allowed or denied. Each table record isidentified by a four-digit card number and contains thecardholder’s name and the permissible access. A cardholder’s accesscan be restricted to a specific time range such as 8 AM to 5 PM.The GateControl software is surrounded by other software, thatprovides functions such as managing the authorization database,checking the transaction log, interfacing to the card reader, andoperating the motor that opens the gate.

Expert Answer


Answer to // GateControl.hpp // #pragma once #include iostream #include string #include utility #include vector using namespace st… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *