Jump to content

Unable to get firstclass value for aircraft


NWA1999

Recommended Posts

Hi,

I'm trying to code functionality within the PIREPData class to divide the inputted passenger amount up into first class, business class,  and economy class,  all randomized but all passengers will make it.  Here's what I've coded 

  $ac = OperationsData::getAircraftByReg($pirepdata['aircraft']);
        $rem=$pirepdata['load'];
        if ($rem<=$ac->firstclass) {
          $first=rand(0,$rem);
          $rem-=$first;
        }
        else {
          $first=rand(0,$ac->firstclass);
          $rem-=$first;
        }
            
        if ($rem<=$ac->busclass) {
          $bus=rand(0,$rem);
          $rem-=$bus;
        }
        else {
          $bus=rand(0,$ac->busclass);
          $rem-=$bus;
        }
          $econ=$rem;
          $rem-=$econ;
          $pirepdata['fclasscount']=$first;
          $pirepdata['bclasscount']=$bus;
          $pirepdata['eclasscount']=$econ;

However all passengers get put in economy. I know my issue is lines like $ac->firstclass, and $ac->busclass. What should these lines be? These values are in my  SQL aircraft table as firstclass, and busclass  columns of each row (aircraft) .

 

Thanks 

Robbie 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...