Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can I get some help filling out the //implimentation functions in c++ for queue_type.h all the pictures are just for refrence on how everything works

can I get some help filling out the //implimentation functions in c++ for queue_type.h all the pictures are just for refrence on how everything works and is tied together. just edit the copied code thank you! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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
what else do you need the instructions are all there in the first picture abd all the codes are given...
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 D un WN Files main.cpp customer_type.c. customer_type.h queue_typen queueADTH server_list_type... server_list_type.h server type.cpp server_typen update_waiting waiting custom 11 15 16 17 18 2e 22 main.cpp 1 #include 2 #include ccmath> 3 #include "customer_type.h" 4 #include "server_list_type.h" 5 #include "waiting customer_queue_type.h" 6 7 8 using namespace std; 9 10 void setsimulationParameters(int& stine, int& numofservers, int& maxiten, int& tBetweencarrival) { 12 cout > Stime; 14 cout > nunofServers; cout > maxiten; cout > Between Arrival; 23 cout 25 26 27 int main() 28 29 int clock; //simulation global clock 30 int time, nunofservers, maxiten, betweenrrival; //simulation parameters 31 int totalnaittine; 32 int customersArrivede; 33 int customersserved.; 34 35 // w Prepare the parameters 36 37 setsimulationParameters(time, numot servers, maxItem, betweenArrival); 38 39 cout exp(- lambda)) { // If a new customer arrives, put him in the queue customertype customer(customer sarrived, clock, e, maxitem); cout 2 #include "customer_type.h" int customerType: :pseudoRandom = 1; 5 6 customerType:: customerType(int id, int anytime, int wtime, int miten) 7 { 8 setCustomerInfo(id, arrviine, wine, miten); 9 } 10 void customerType::setCustomer info(int id, int arrvtine, int wtime, int mitem) 12 { customerlumber = id; arrivaltine - arrvtime; 15 waitingTime = time; maxItem - miten; if (miten -- 0) { numofitem = m; } else { pseudoRandom . (pseudorandon 3+1)% maxIten; 21 numofitem = pseudorandon + 1; // number of item is 1 to max 22 3 } int custonertype::getuaitingtine() const { return waitingtime; 28 } void customerType::setraitingtine(int tine) { waitingtime = time; } 23 24 25 26 27 35 void customertype::incrementiaitingtine() 36 { 37 waitingTime--; 38 } 39 40 int custonerType::getarrivalTime() const { return arrivaltime; 43 } int customerType: :getrunofitem() const 46 { return numofitem; 41 42 44 45 48 } se 51 52 53 int customerType::getCustomerlumbert) const { return customer Number; ) Files le main.cpp customer_type.c... customer_type.hu queue_type.h queueADT. server_list_type... server_list_type.h server_type.cpp server_type.h update_waiting waiting custom... 12 13 14 15 16 customer_type.h 1 #ifndef CUSTOMER_TYPE_H 2 #define CUSTOMER_TYPE_H 3 4 class customerType 5 { 6 public: 7 customerType(int id = 0, int arrvtime = 0, 8 int wtime = @, int mitem = 0); 9 void setCustomerInfo(int id = e, int intime = 0, int wtime = 0, int mitem = 0); 11 int getwaitingTime() const; void setwaitingTime(int time); void incrementwaitingTime(); int getarrivalTime() const; int getNumofitem() const; int getcustomerNumber() const; 17 18 private: int customerNumber; 20 int arrivaltime; int waitingTime; 22 int maxItem; 23 int numofitem; 24 static int pseudo Random; }; 26 27 #endif // !CUSTOMER_TYPE_H 19 21 25 N 4 Files main.cpp customer_type.c... customer_type.h queue_type.h queueADTH server_list_type... server_list_typen server_type.cpp server_type.h update_waiting waiting custom... queue ADT.h 1 #ifndef QUEUE_ADT_H #define QUEUE_ADT_H 3 template 5 class queueADT 6 { 7 public: 8 virtual bool isEmptyqueue () const = 0; 9 virtual bool isFullqueue() const = 0; 10 virtual int getsize() const = 0; 11 virtual int getMaxCapacity) const = 0; 12 virtual void initializeQueue () = 0; 13 virtual Type front) const = 0; 14 virtual Type back() const = ; 15 virtual void enqueue(const Type& queueElement) = 0; 16 virtual void dequeue = 0; 17 }; 18 19 #endif // !QUEUE_ADT_H 20 Files main.cpp customer_type. customer_typeh queue_typen QUOADTA server_list_type1 server_list_type. server_type.cop Dserver_typen update Waiting waiting custom server stype.cpp 1 include "server_list_type.h" 2 3 using namespace std; 4 5 Server ListType: serveristType(int nun) 6 7 unofservers servers net serverType(nu); 10 serveristype: :-serverListType> 12 13 delete) servers; 14 ) 15 16 int serveristtypergetFreserverio const 17 int serverio 15 19 for (int i . *; i return serverio 25 > 27 28 int serverListType: getirumberofusyservers() const 31 33 14 35 36 37 38 Int busyServers ; for (int i . ; 1 nunofservers; i++) if (servers[1]. 1sFree busyServers; return busyServers; } veid serverListType: :SetServersusy(int serverid, customertype Custoner, Int Time) serversserverto).setusy(); serversserverID).setCurrentItem(Tine); servers/serverID).setCurrentCustomer Customer); 47 se 51 52 54 55 56 57 55 59 void serverListType::setservertusy (int serverid, customertype customers int itencoustoner.getUsOfEten); servers(server).setBusy(); servers serverID).setCurrentumfitentem); Serversserverid).setCurrent customer customer); 7 void serverListTypest updateservers(std::estreant outFile) for (int i = 0; i > 1 servers(1).decrease TransactionTime(); sf (servers[1].getrenaining transactionTime() -->) + outFile 12 void serverType::setusy() 15 16 status . "buy": 17 3 19 19 void servertypesetree 20 1 status - "free"; 2 20 void serverType::setCurrentinofiten(int t) 25 26 current unfitent 1 void servertype::setCurrentIten() currentes current customer-setumofitem(); 3 20 29 30 31 32 33 34 35 36 37 38 39 int serverType:Egetrensining transactiontime() const 1 return current inten; 2 vold senertype: decrease transactionTime() current unfiten 3 46 55 void servertype: setCurrentCustomer customerType Customer 1 current customer-customer 2 47 50 51 52 int server type: getCurrentCustoneribert) const 1 return currentCustomer.getCustomerlumber(); > 54 55 56 57 58 59 se 63 62 63 int serveripessetCurrentCustonerArrival Time) const { return current customer.getarrivoltine(); > Int serverType::getCurrent customersiastingtinet) const return current customer.getiitingine(); > 1 int serverType:getCurrentCustomernofiten() const 65 66 return current Customer.getofiten(); Files main.cpp customer_type.c... customer_type.h queue_type.h WSON OWN queueADT.h server_list_type.... server_list_type.h server_type.cpp server_type.h update_waiting_ waiting custom... server_type.h 1 #ifndef SERVER_TYPE_H 2 #define SERVER_TYPE_H 3 4 #include 5 #include "customer_type.h" 6 7 class serverType 8 { 9 public: 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; 22 int getCurrentCustomerNumofitem() const; 23 24 private: customerType currentCustomer; 26 std::string status; int currentNumofitem; }; 29 #endif // ISERVER_TYPE_H 25 27 28 3e 21 Files : update_waiting_queue_type.cpp 1 #include "waiting customer_queue_type.h" main.cpp customer_type.c. customer_type.h queue_type.h queueADT.h server_list_type.... server_list_typen server_type.cpp server_type.h update_waiting waiting_custom.. waitingcustomerQueueType::waitingcustomerQueueType(int size) queueType (size) { 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 } void waitingcustomerqueueType::updatewaitingQueue () { customerType cust; cust.setwaitingTime(-1); int wTime=; enqueue (cust); while (wTime != -1) { cust = front(); deQueue(); wTime = cust.getwaitingTime(); if (wtime == -1) break; cust.incrementwaitingTime(); enQueue (cust); } Files : main.cpp waiting customer_queue_type.h 1 #ifndef WAITING_CUSTOMER_QUEUE_TYPE_H 2. #define WAITING_CUSTOMER_QUEUE_TYPE_H 3 4. #include "customer_type.h" 5 #include "queue_type.h" 6 7 8 class waitingcustomerqueueType : public queueType 9 { 10 public: waitingcustomerQueueType(int size = 100); 12 void updatewaitingQueue (); 13 }; 14 15 #endif // WAITING_CUSTOMER_QUEUE_TYPE_H I customer_type.c... customer_type.h queue_type.h queueADT. server_list_type.... server_list_type.h server_type.cpp server_type.h update_waiting waiting_custom... 11 16

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

Advances In Spatial And Temporal Databases 8th International Symposium Sstd 2003 Santorini Island Greece July 2003 Proceedings Lncs 2750

Authors: Thanasis Hadzilacos ,Yannis Manolopoulos ,John F. Roddick ,Yannis Theodoridis

2003rd Edition

3540405356, 978-3540405351

More Books

Students also viewed these Databases questions

Question

suggest a range of work sample exercises and design them

Answered: 1 week ago