Need help with this homework don't know how to start create the polling loop
In the main() function, a Sender object (called tx), a Receiver object (called rx) and a queue object(called q) are created. The code should be added between the comments of "add your code here".The objective of the software is to transmit the data from the sender to the receiver via a queuein the fastest amount of time given the data rate constraints of the Sender object and the Receiverobject. The Queue class is provided to you. In the main() function, you should createa polling loop. This polling loop should check the status of the Sender object to see if thestream is open and if there are any characters that need to be sent. If characters are retrieved from theSender object, then they should be put on the queue. Next, the polling loop should check the status of theReceiver object to see if characters can be received. If characters can be received and there arecharacters on the queue to send, then take the number of allowed characters off the queue and sendthem to the Receiver object. The polling loop should be terminated when the Sender class stream is closedand the queue is empty.
It's just a loop. Just write a loop and do what the instructions say, sentence by sentence.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
while (not_finished)
{
// check the status of the Sender object to see if thestream is open and if there are any characters that need to be sent
if (tx.isOpen() && tx.there_are_characters_to_be_sent())
{
// If characters are retrieved from theSender object, then they should be put on the queue
string characters = tx.getCharacters();
if (characters.size() > 0) // if we got some characters
{
q.put_characters_on_queue(characters);
}
}
// Next, the polling loop should check the status of theReceiver object to see if characters can be received.
if(rx.can_receive_characters())
{
... etc etc