16 this exercise gives some programming practice with dynamic arrays but is part of 5347119

16. This exercise gives some programming practice with dynamic arrays, but is part of a larger project. continued in Chapters 5 and 8. Write a class called ServerGroup, which will be a sim~ ple custom-made data structure. It will be a special-purpose class, so it will be untemplated. Recall that you must #include files differently for untemplated classes. This is the ?rst of three programs that will be combined to form a larger project. You can think of the Server- Group as a class that will serve people waiting in line. The private section of the ServerGroup class will have a pointer to a dynamic integer array called servers, an integer variable called spServer (a special-purpose server), and an integer variable called freeServer. It will also be useful to have a variable called size, for the number of elements in the dynamic array.Then write the following functions for the class: a. The constructor will pass in an integer parameter that will be used to set the number of el- ements in the dynamic integer array. (This number is actually the number of general-pun pose servers.) The constructor will also set all elements of the array to 0 and spServer to O. b. Write a function called spServerFree that will return true if spServer is 0 and return false otherwise. (The integer value is. the number of clock ticks until the special-pur- pose server is free; if the integer value is 0, the special-purpose server is already free.) c. Write a function called serverFree that will return true if it finds a () in the array and false otherwise. (These integers also represent the number of clock ticks until the corre- sponding servers are free.) If the function ?nds a () in the array, it will set freeServer to the index of that element. (freeServer has the index of one of the servers that are free.) d. Write a function called useServer that will pass in an integer parameter, avTransTime, and set servers[freeServer ] to avTransTime. (avTransTime is the average transaction time, in clock ticks, to serve a person in line.) e. Write a function called usespServer that will pass in an integer parameter, av- TransTime, and set spServer to avTransTime. (This is the same function as in (d), except that it is for the special-purpose server whereas (d) is for the general-purpose servers.) f. Write a function called decServers that will decrement spServer by 1, unless spServer is already 0. (If it is 0, it stays the same.) The decServers function will also decrement each element in the array by 1, unless the element is already (). For example, if the array is 0 5 6 () () It). then after decServers is called, the array will be 0 4 5 0 0 9. (You guessed it, this function is called when a clock tick of time elapses.) To test your class, you might want to write a temporary print function in the class to print out the values of the array and the other private variables. Once you are sure that everything works. delete the print function.

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now