Game Development Reference
In-Depth Information
float Utility;
Utility =
( WorksOdds() * -mWarrantyPrice )
+ ( mRepairOdds * -mWarrantyPrice )
+ ( mReplaceOdds * -mWarrantyPrice );
return Utility;
};
float MyGame::UtilityNotWarranty()
{
// Returns the utility value of not purchasing the warranty.
float Utility;
Utility =
( mRepairOdds * -mRepairCost )
+ ( mReplaceOdds * -mComputerCost );
return Utility;
};
bool MyGame::PurchaseWarranty()
{
// Returns the decision on whether or not to purchase the
// warranty based on the relative utility values returned from
// the two functions.
if ( UtilityWarranty() > UtilityNoWarranty() ) {
return true;
} else {
return false;
}
};
Search WWH ::




Custom Search