Project 1: The Genius Bar (a very simple one) The Genius Bar is a technical-support station located inside Apple retail stores to provide concierge-style support for customers of Apple products. Customers who experience problems with their Apple products may enter an Apple retail store and seek assistance. They are greeted by an employee who takes their information and either assigns them to a technician for help or gives them an wait time. Technicians or "Geniuses" float in the Genius Bar area assisting customers and troubleshooting. When a Genius is finished with a customer, he/she can move on to help another. Design a simple program for scheduling at the Genius Bar Class Customer Represent a customer's information the customer's name the type of device that is malfunctioning the customer's wait time Provide an interface to access that information return the customer's name return the type of problematic device return their wait time update their wait time Class GeniusBar Represent the information necessary for assigning geniuses to help customers the total number of geniuses working in the store the maximum number of customers that can sit around the genius bar area (either waiting or being helped) a time increment for the customer's wait time the current wait time the number of geniuses currently available to help customers the number of customers currently waiting to be helped the genius bar where the customers sit waiting to be helped Provide an interface to manage the genius bar add a customer to the genius bar assign a genius to assist a customer a genius has completed his work, so release him and make him available again to assist other customers update the wait time of customers waiting at the genius bar 8/28/2018 Project1
The task: For this project you are given below the full class interface for both the Customer class and the GeniusBar class (Customer.hpp and GeniusBar.hpp ) as well as a sample usage main() function. You need to write and submit the implementation (Customer.cpp and GeniusBar.cpp) Things to note: There is no Genius class. Geniuses are anonymous in this Genius Bar and they can all perform the same tasks, so all we really need to simulate a genius is to track whether there are geniuses available to help customers. The only variables keeping track of the geniuses in the GeniusBar class are number_of_available_geniuses, and the total number of geniuses working in the store TOTAL_NUMBER_OF_GENIUSES. This is a pretty unfair Genius Bar, the last Customer that arrives gets help from a Genius first We will talk about this and fix it later in the semester. Read the comments in the interface carefully, they are there to help you implement those functions. There are no comments where the function implementation is trivial and fully described by the function prototype (the name of the function along with its parameters and return type). The interface: Below are the full class declarations for Customer and GeniusBar class Customer{ public: Customer(); //default constructor Customer(string name, string device = "unknown", int wait_time = 0); //parameterized constructor //return: name_ string getName(); //return: defective_device_ string getDevice(); //return: wait_time_ int getWaitTime(); //post: wait_time_ = new_wait_time void updateWaitTime(int new_wait_time); private: string name_; string defective_device_; int wait_time_; }; // end Customer class GeniusBar { public: 8/28/2018 Project1
GeniusBar(); //default constructor //pre: number_of_customers_ < MAX_NUMBER_OF_CUSTOMERS //post: add new_customer to genius_bar_ and increment current_wait_time_ by WAIT_TIME_INCREMENT //return: true if number_of_customers_ < MAX_NUMBER_OF_CUSTOMERS, false otherwise bool addWaitingCustomer(Customer& new_customer); //pre: (number_of_customers_ 0) && (number_of_available_geniuses_ 0) //post: decrement number_of_customers_ and number_of_available_geniuses_ //return: true if (number_of_customers_ 0) && (number_of_available_geniuses_ 0), false otherwise bool assignGeniusToCustomer(); //pre: number_of_available_geniuses_ < TOTAL_NUMBER_OF_GENIUSES //post: increment number_of_available_geniuses //return: true if number_of_available_geniuses_ < TOTAL_NUMBER_OF_GENIUSES, false otherwise bool releaseGenius(); //pre: number_of_customers_ 0 //post: increment the wait time of each customer on the genius_bar by WAIT_TIME_INCREMENT //return: true if number_of_customers_ 0, false otherwise bool updateCustomersWaitTime(); private: static const int TOTAL_NUMBER_OF_GENIUSES = 3; static const int MAX_NUMBER_OF_CUSTOMERS = 5; static const int WAIT_TIME_INCREMENT = 5; int current_wait_time_; int number_of_available_geniuses_; int number_of_customers_; Customer genius_bar_[MAX_NUMBER_OF_CUSTOMERS]; }; //end GeniusBar Usage: Here is a usage example. When testing your code please use this exact main function. int main() { //initialize a GeniusBar GeniusBar genius_bar; //create some customers Customer customer1("Lina", "iPhone"); cout << customer1.getName() << " has problems with " << customer1.getDevice() << endl; Customer customer2("Clay", "iPad"); cout << customer2.getName() << " has problems with " << customer2.getDevice() << endl; Customer customer3("Rory", "iMac"); cout << customer3.getName() << " has problems with " << customer3.getDevice() << endl; Customer customer4("Liam", "macBookPro"); cout << customer4.getName() << " has problems with " << customer4.getDevice() << endl; Customer customer5("Adri", "iPhone"); cout << customer5.getName() << " has problems with " << customer5.getDevice() << endl; Customer customer6("Sky", "macBookAir"); cout << customer6.getName() << " has problems with " << customer6.getDevice() << endl; cout << endl << "add customers to the geinus bar \n"; cout << genius_bar.addWaitingCustomer(customer1) << endl; // true (1) cout << customer1.getName() << "'s wait time is now " << customer1.getWaitTime() << endl; cout << genius_bar.addWaitingCustomer(customer2) << endl; // true (1) cout << customer2.getName() << "'s wait time is now " << customer2.getWaitTime() << endl; cout << genius_bar.addWaitingCustomer(customer3) << endl; // true (1) 8/28/2018 Project1
cout << customer3.getName() << "'s wait time is now " << customer3.getWaitTime() << endl; cout << genius_bar.addWaitingCustomer(customer4) << endl; // true (1) cout << customer4.getName() << "'s wait time is now " << customer4.getWaitTime() << endl; cout << genius_bar.addWaitingCustomer(customer5) << endl; // true (1) cout << customer5.getName() << "'s wait time is now " << customer5.getWaitTime() << endl; cout << genius_bar.addWaitingCustomer(customer6) << endl; // true (0) cout << customer6.getName() << "'s wait time is still " << customer6.getWaitTime() << " because there is no more space at the genius bar \n"; cout << "Sorry Sky please come back later!\n\n"; cout << endl << "assigning geniuses to assist customers:" << endl; cout << genius_bar.assignGeniusToCustomer() << endl; // true (1) cout << genius_bar.assignGeniusToCustomer() << endl; // true (1) cout << genius_bar.assignGeniusToCustomer() << endl; // true (1) cout << genius_bar.assignGeniusToCustomer() << endl; // true (0) cout << "Oops, no more available geniuses, the remaining customers must wait \n\n"; cout << endl << "release some geniuses from helping customers and make them available again \n"; cout << genius_bar.releaseGenius() << endl; // true (1) cout << genius_bar.releaseGenius() << endl; // true (1) cout << genius_bar.releaseGenius() << endl; // true (1) cout << genius_bar.releaseGenius() << endl; // true (0) cout << "no more geniuses to be released \n\n"; cout << "Oops, it's lunch time, our geniuses are going on lunch break, better update the remaining customers' wait time \n"; cout << genius_bar.updateCustomersWaitTime() << endl; // true (1) cout << endl << "Ok, our geniuses are back from lunch, assign more geniuses to help the remaining customers \n"; cout << genius_bar.assignGeniusToCustomer() << endl; // true (1) cout << genius_bar.assignGeniusToCustomer() << endl; // true (1) cout << genius_bar.assignGeniusToCustomer() << endl; // true (0) cout << "no more customers in the store, all done for today!!! \n\n"; cout << "do we need to tell any remaining customers that they need to wait unitl tomorrow? \n"; cout << genius_bar.updateCustomersWaitTime() << endl; // true (0) cout << "no we don't, good night!!! \n\n"; return 0; } Submission: Your project must be submitted on Gradescope. The due date is September 4 by 9pm. Feel free to submit early!!! Multiple submissions are allowed, only the last submission will be graded. No late submissions will be accepted. Submit Customer.cpp and GeniusBar.cpp ONLY. Your code will be tested with the above main function for grading, so make sure your code runs without problems with the above main function. Your files should include a preamble comment with the following information: file name, your name, date, assignment (e.g. CSCI 235, Fall 2018, Project 1) and a brief description. Have Fun!!!!!