home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / DOOG / CPTUTOR2.ZIP / ANSWERS.ZIP / CH07_3B.CPP < prev    next >
Text File  |  1990-07-20  |  523b  |  33 lines

  1.                              // Chapter 7 - Programming exercise 3
  2. #include "truck.hpp"
  3.  
  4. void truck::init_truck(int how_many = 2, float max_load = 24000.0)
  5. {
  6.    passenger_load = how_many;
  7.    payload = max_load;
  8. }
  9.  
  10.  
  11. float truck::efficiency(void)
  12. {
  13.    return payload / (payload + get_weight());
  14. }
  15.  
  16.  
  17. int truck::passengers(void)
  18. {
  19.    return passenger_load;
  20. }
  21.  
  22.  
  23. int truck::total_weight(void)
  24. {
  25.    return (payload + get_weight());
  26. }
  27.  
  28.  
  29.  
  30. // Result of execution
  31. //
  32. // (this file cannot be executed)
  33.