Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Scenario. You have just been hired at a Start Up company that has an innovative new product. It has a floor mat that, in

The Scenario. You have just been hired at a Start Up company that has an innovative new product. It has a floor mat that, in combination with cameras and new AI technology, can detect a person's walking direction, gender, age range, weight, height and report that to a Raspberry PI. This technology can be used to report presence ratios and can be used as part of security systems to quickly research without having to physically view hours of video. This can also be used with point of sale systems to detect ratios of sales to people in buildings, etc. This is will also give building managers information in property usage to better manage environmental settings. There are many other potential applications as well as the possibility that even more data could be derived. You have been asked to develop a beta program in C++ to keep track of people in a building. The program will receive events and data that goes along with those events. The events are: 0 - Entrance with a data string 1 - Exit with a data string 2 - No operation Your tasks: Loop and process events. When an Entrance event occurs, create a string dynamically and store the pointer to that string in an array. Keep track of the number of entrance events. When an Exit event occurs, locate the pointer for the string, delete the pointer and replace the pointer address in the array with NULLPTR. You may get delete messages for entries that are not in your array. You can simply log that condition. Keep track of the number of exit events. For both the Entrance and Exit event occurs, display a list of people that are currently in the building If a NoOP is received, simply try again. Your loop will exit under the following conditions: 1. Program has received 1000 events OR 2. The people array has reached its limit. 
// MS Visual Studio 2015 uses "stdafx.h" - 2017 uses "pch.h" //#include "stdafx.h" //#include "pch.h" #include  #include  #include "windows.h" #include "cosc-1437-4a.h" using namespace std; // forward declarations void initializePeopleArray(); void showLoadedData(); /* The good way to debug your program is to change the const variables below. Start smaller and work things up. */ const int MAX_PEOPLE_COUNT = 100; const int MAX_LOOP_COUNT = 1000; const int SLEEP_TIME = 750; // These definitions are in cosc-1437-4a.h // const int ENTRANCE = 0; // const int EXIT = 1; // const int NO_OP =2; // see https://www.tutorialspoint.com/cplusplus/cpp_array_of_pointers.htm string *people[MAX_PEOPLE_COUNT]; int main() { initializePeopleArray(); int x = 0; while (x < MAX_LOOP_COUNT) { x++; int event = getEvent(); cout << "event = "<< event< 

//This code generates mock data for user traffic // MS Visual Studio 2015 uses "stdafx.h" - 2017 uses "pch.h" //#include "stdafx.h" //#include "pch.h" #include "cosc-1437-4a.h" #include  #include  #include  #include  using namespace std; // These definitions are in cosc-1437-4a.h // const int ENTRANCE = 0; // const int EXIT = 1; // const int NO_OP =2; bool loaded = false; vectormyList; string eventData; string getAge() { int start_age = ((rand() % 6) * 10) + 10; int end_age = start_age+10; return to_string(start_age)+"-"+to_string(end_age)+" years old"; } string getWeight() { return to_string((rand() % 300) + 40)+ " pounds"; } string getGender() { int gender = rand() % 2; if (gender) { // == 0 return "Female"; } return "Male"; } string getHeight() { return to_string((rand() % 80) + 40)+ " inches tall"; } string getId() { string s = to_string(rand()); return s; } string createNewData() { return getId()+","+getGender()+","+getWeight()+","+getHeight()+","+getAge(); } void addNew() { string data = createNewData(); myList.push_back(data); } void showData() { for (string data:myList) { cout << data << endl; } } string getEventData() { return eventData; } int getEvent() { if (!loaded){ // Prep with preloaded data loaded = true; srand(int(time(0))); // seed rand so values always change for each run // for (int x =0;x<5;x++){ // addNew(); // } } int event = rand() % 3; if (event == ENTRANCE ) { // add string data = createNewData(); eventData = data; myList.push_back(data); } if (event == EXIT ) {// delete if (myList.size() ==0 ) { event = NO_OP; } else { int deleteIDX = rand() % myList.size(); eventData = myList[deleteIDX]; myList.erase(myList.begin()+deleteIDX); } } if (event == NO_OP) { eventData == ""; } return event; }

// MS Visual Studio 2015 uses "stdafx.h" - 2017 uses "pch.h" //#include "stdafx.h" //#include "pch.h" #include  using namespace std; //// forward declarations that exist in COSC-1437-4a int getEvent(); string getEventData(); string getAge(); string getWeight(); string getGender(); string getHeight(); string getId(); string createNewData(); const int ENTRANCE = 0; const int EXIT = 1; const int NO_OP =2; 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions