Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

queue_type.h template class queueType : public queueADT { public: queueType(int queueSize = 100) { // implement constructor } ~queueType() { // implement destructor } bool

image text in transcribed
queue_type.h
template
class queueType : public queueADT
{
public:
queueType(int queueSize = 100) {
// implement constructor
}
~queueType() {
// implement destructor
}
bool isEmptyQueue() const {
return (count == 0);
}
bool isFullQueue() const {
return (count == maxQueueSize);
}
int getSize() const {
return count;
}
int getMaxCapacity() const {
return maxQueueSize;
}
void initializeQueue() {
// implement function
}
Type front() const {
assert(!isEmptyQueue());
return list[queueFront];
}
Type back() const {
assert(!isEmptyQueue());
return list[queueRear];
}
void enQueue(const Type& queueElement) {
// implement function
}
void deQueue() {
// implement function
}
private:
int maxQueueSize; //variable to store the maximum queue size
int count; //variable to store the number of
int queueFront; //variable to point to the first
int queueRear; //variable to point to the last
Type* list; //pointer to the array that holds
};
#endif // !QUEUE_TYPE_H
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
you do not need to copy the whole code all you would need is copy the queue_type.h then fill out the //implimient fuctions in c++ the rest is just for refrence.
In this exercise you will have to simulate a queuing system. All the necessary classes are provided to you. Here is a summary of the available classes: customer Type: this class is used to create customer objects to add to the queue. It stores useful information about the customer such as customer number, arrival time, waiting time and transaction time. Code is provided and shall be used as is serverType: this class is used to create server objects. Customers go to servers to complete their transaction. Each server can serve only one customer at the time, so it is always set as either busy or free. Code for this class is provided and shall be used as is! serverListType: a list of server created at the beginning of the simulation (the number of servers is part of the parameters) serverListType keeps track of what servers are available. A very important function of serverListType is updateServers, which is used at each iteration to determine if a server has become available. Code for this class is provided and shall be used as is waiting CustomerQueueType: this class inherits from the queue Type class and adds only a method (beside the constructor). updateWaitingQueue(). This method is used to increment the waiting time of each customer in the queue. main.cpp controls the execution of the queueing system Code is provided and shall be used as is! queue Type: the queue that customers join when they first arrive queueType inherits from the abstract class queueADT, which has the only goal of stipulating the requisites of a queue class. You can look at each file for more details regarding the classes implementations and how they work The main function starts with the creation of the necessary variables for the simulation. These include a clock (a counter to simulate the passing of time), the simulation parameters (total simulation time, number of servers, transaction time, and average time between customers arrival), total waiting time total customers arrived and total customers served Additionally, you will need the queue (waitQueue). a list of servers (servers) and a customer object (customer). For more explanation, please view the short video on Queue Simulation available in Teams. Your task is to complete the array based queue implementation in queueuType h Please revisit the PDSO9Queues slides and video on array based implementations of Queues. Specifically the following items need to be added: Constructor provide the code for the queue constructor taking as an argument the maximum number of elements in the array used to manage the queue. If no parameter is provided by the user code to the constructor, the maximum queue size shall be 100. If a negative parameter is provided to the constructor, the maximum queueu size shall be 100. Destructor provide the code clean up the queue. enQueue provide the code to add an element to the queue. If the queue is full, your code is supposed to return the error message: Can not add to a full queue deQueue: provide the code to remove an element from the queue. If the queue is empty, your code is supposed to return the error message Cannot remove from an empty queue Files D main.cpp customer_type.c... @customer_type.h D queue_type.h queueADT. server_list_type. server_list_type.h server_type.cpp server_type.h update_waiting.... Dwaiting_custom... customer_type.h 1 #ifndef CUSTOMER_TYPE_H 2 #define CUSTOMER_TYPE_H 3 4 class customertype 5 { 6 public: 7 customerType(int id = e, int arrvtime = 0, 8 int wtime = , int nitem = a); void setCustomerInfo(int id = e, int intime = 0, 10 int wtime = e, int mitem = 0); 11 int getwaitingTime() const; 12 void setwaitingTime(int time); 13 void incrementwaitingTime(); 14 int getarrivalTime() const; 15 int getNumofitem() const; 16 int getcustomerNumber() const; 17 18 private: 19 int customer Number; 20 int arrivalTime; 21 int waitingtime; 22 int maxitem; 23 int numofitem; 24 static int pseudoRandom; 25 }; 26 27 #endif / CUSTOMER_TYPE_H 28 Files main.co main.cpp 1 include > Stine cout > nurofservers cout > matem; cout > toe encarrival: cout W sf there is servers to susteet to be the custonerType customer customer Queue.front (3) customer Queue, dequeue 78 79 se 81 82 serverlist.setServersusy (serverlist.getFreeServerID(), customer); totalwaittine totalwaitine customer.setiaitingTime03 customersserved 2 14 35 86 87 88 89 ga 91 52 93 94 95 96 97 98 cout Cla55 queue ADT Dcustomer_typeh De queue type h 2 queueADT. server listetype te 11 12 13 publies virtual bool isempty Queue (const se; virtual bool is Full Queue conste; virtual int getsize const virtual int getmaxcapacity consta virtual void initializequeue Virtual Type fronto const - e. virtual Type back const virtual vaid enqueueconst Type& queueElement ; virtual vold dequeue ( server list.type.h C server type.cpp 15 16 1 server lypeh update welling waiting custom Hendif Hana 2e Files server_type. #include "server_list_type. > min.cpp customer_type customer typen 1 4 5 6 7 using space std; serveristtype serverListType(int nun) murofservers = num; servers. w server typenun: 3 10 serverListType::-serveristType() 12 delete servers DUDADES server_listype Serveen serverype.coop Derve byen update, went Dwiting custom 3 14 15 16 int ServerlisttyperpetfreeserverID) const 18 15 20 22 23 24 int servert 13 for (int 120euroservers: 1) if (servers[1]. Street { serverID = 3 break return server 10 > 26 27 20 29 30 int serverListType: getuberofusservers (y const 32 int busyservers - for (int 1-1 ofservers; 1 (servers[i] is Free busyservers return bosservers 3 35 30 void servertist Typesasetserverusy Cint serverto, customerType Customer sine 30 39 40 41 42 43 servers serverio].setusy servers Server ID).setCurrentofitentTime) servers/serverio).setCurrent customer customer) 2 void servert istType: Esetservertusy(int server ID, Custonentyse customer) 45 48 int iten = customer.getrofite) servers[server 10].setusy: servers[serverio).setCurrentofitentes) servers [serverID).setCurrentCustomer customer 3 void serveristtype updateservers(std:ostren outile) 51 52 53 54 55 56 57 59 for (int i = 0; i 5 #include "customer_type.h" 6 #include "server_type." 7 8 9 class serverListType 1e queue typen queueADLA 12 19 server_list_type... server_list_type.h: server type server typech update_waiting waiting custom publict serverListType(int num = 1); serverListType(); int getFreeServerID() const; int getNumberOfBusyservers() const; void setserverBusy(int serverio, customertype customer, Int times void setserverBusy(int serverin, customerType customer Void updateservers(std::ostream& outFiles 15 16 17 78 19 2e 23 22 23 24 25 26 private: int numofservers; serverType servers; #endif TISERENDER Files envert 1 winclude "server_type." Servery petserverType) status free current unfiten > MCDO > customer_type custome_type -queue Type: DURADTH ivet type server_list_type server type.co bool serverTypeisprec) const 10 return (status="free"): void serverTypesettusy status busy 13 14 15 16 17 IN 19 20 21 Dwaiting custom void serverpest Free status for voto servertypesetCurrentofitent t) currentoftet; 2 25 36 27 25 25 3e 31 32 33 void serverType::setCurrentofite) currentuofiter - current customer.getUnofiten 1 Int servertypet pet remaining transactiontine() const return currentofiten; 2 void serverType: decrease TransactionTime) currentNunofite 2 42 43 40 45 66 vofd ServerTypesisetCurrentCustomer customertype customer currentCustomer Customers 1 int serverType: getCurrentCustomerliber const return currentCustomer.getCustoernber(); 2 int serverTypestgetCurrentCustomer arrivalTime() const return current customer.getarrivaltime; 3 int servertypet.getCurrentCustomerieitingtime(const return currentCustoner.getisaltirgine 56 57 58 59 se 61 62 63 64 65 55 67 int server TypergetCurrentCustomer often const return current customer.getfiten Files 1 main.cpp customer_type.c... 4 5 customer_type.h O queue_type.h O queueADTH server_list_type.... server_list_type.h server_type.cpp server_type.h updatlaiting... waiting_custom... server_type.h #ifndef SERVER_TYPE_H 2 #define SERVER_TYPE_H 3 #include #include "customer_type.h" 6 7 class serverType 8 { 9 public: 10 serverType(; 11 bool isFree() const; 12 void setBusy(); 13 void setFree(); 14 void setCurrentNumofitem(int t); 15 void setcurrentNumofitem(); 16 int getRemainingTransactionTime() const; 17 void decreaseTransactionTime(); 18 void setCurrentCustomer (customerType ccustomer); 19 int getCurrentCustomerNumber() const; 20 int getCurrentCustomerArrivalTime() const; 21 int getCurrentCustomerwaitingTime() const; int getCurrentCustomernumofitem( const; 23 24 private: 25 customerType currentCustomer; 26 std::string status; 27 int currentNumofitem; 28 }; 29 3e #endif L SERVER_TYPE_H 31 22 32 Files BD update waiting queue_type.cpp #include waiting customer queue_type.h" 1 2 main.cpp customer type.co 4 5 waitingcustomerqueueType:: waitingcustomerqueueType(int size squeueType (size) { customer type.h 6 D queue_type.h 3 E queueADT.h void waitingcustomerQueue Type: : updatewaitingQueue cserver_list_type... 7 8 9 10 11 12 13 14 D server_list_type.h server type:epp customerType cust; cust.setwaitingTime(-1); int wTime=; enQueue ( cust); while (wTime = -1) D server_typen 15 16 17 18 update_waiting waiting stom 19 20 21 22 cust. fronto: deQueue (); wTime cust.getwaitingTime(); if (wtime == -1) break: cust.incrementwaitingTime(); enqueue(cust) 23 24 25 26 3 27

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

13. What change in the brain is responsible for musicians cramp?

Answered: 1 week ago