#Code won't trigger a conditional statement

9 messages · Page 1 of 1 (latest)

civic jetty
#

while(!cpuStack.empty() && !arrivalStack.empty())
{
if (total_finish_time <= largest_arrival_time)
{
arrivalStack.top()->finish_time += 1;
arrivalStack.top()->cpuCycle -= 1;
total_finish_time += 1;
std::cout << arrivalStack.top() << " " << arrivalStack.top()->finish_time << std::endl;
std::cout << cpuStack.top()->arrivalTime << std::endl;

    if (arrivalStack.top()->finish_time == cpuStack.top()->arrivalTime)
    {
        std::cout << "start";
        if (arrivalStack.top()->cpuCycle > cpuStack.top()->cpuCycle)
        {
            temp_cpu_queue.push(arrivalStack.top());
            arrivalStack.pop();
        }
    }
    if (arrivalStack.top()->cpuCycle == 0) 
    {
        arrivalStack.pop();
    }
   
}
icy heronBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

icy heronBOT
#

while(!cpuStack.empty() && !arrivalStack.empty())
{
```cpp
if (total_finish_time <= largest_arrival_time) {
arrivalStack.top()->finish_time += 1;
arrivalStack.top()->cpuCycle -= 1;
total_finish_time += 1;
std::cout << arrivalStack.top() << " " << arrivalStack.top()->finish_time
<< std::endl;
std::cout << cpuStack.top()->arrivalTime << std::endl;

if (arrivalStack.top()->finish_time == cpuStack.top()->arrivalTime) {
std::cout << "start";
if (arrivalStack.top()->cpuCycle > cpuStack.top()->cpuCycle) {
temp_cpu_queue.push(arrivalStack.top());
arrivalStack.pop();
}
}
if (arrivalStack.top()->cpuCycle == 0) {
arrivalStack.pop();
}
}

YoimiyaSimpu
civic jetty
#

it won't trigger the if (arrivalStack.top()->finish_time == cpuStack.top()->arrivalTime)
{ conditonal

shy ravine
#

what is the type in this stack?

civic jetty
#

class stack

#

i think I fixed it when I did

#
 arrivalStack.top()->finish_time += 1;
  arrivalStack.top()->cpuCycle -= 1;
  total_finish_time += 1;
``` at the end of the if statement