00001 // Fuel_Tank.h - a particle that holds fuel for the engine. 00002 // 00003 // Copyright (C) 2002 Sam Varner 00004 // 00005 // This file is part of Vamos Automotive Simulator. 00006 // 00007 // This program is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 2 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 #ifndef _FUEL_TANK_H_ 00022 #define _FUEL_TANK_H_ 00023 00024 #include <vamos/body/Particle.h> 00025 #include <vamos/geometry/Three_Vector.h> 00026 00027 namespace Vamos_Body 00028 { 00029 //* A fuel tank particle. 00030 class Fuel_Tank : public Particle 00031 { 00032 // The capacity of the tank. 00033 double m_capacity; 00034 00035 // The remaining volume of fuel. 00036 double m_volume; 00037 00038 // The denisty of the fuel. 00039 double m_density; 00040 00041 // update_mass () is called to re-calculate the mass of fuel 00042 // remaining. 00043 void update_mass () { m_mass = m_density * m_volume; } 00044 00045 public: 00046 //** Constructor 00047 Fuel_Tank (const Vamos_Geometry::Three_Vector& position, 00048 double capacity, 00049 double volume, 00050 double density); 00051 00052 // Put fuel in the tank. With the default VOLUME of -1.0, the 00053 // tank is filled to capacity. With any other negative VOLUME, or 00054 // zero, the tank is emptied, i.e. the volume is set to zero. 00055 void fill (double volume = -1.0); 00056 00057 // Decrease the volume of fuel by AMMOUNT. The volume remaining 00058 // is returned. 00059 double consume (double amount); 00060 00061 // Return the volume of fuel remaining. 00062 double fuel () const { return m_volume; } 00063 00064 double fuelpercent() const {return m_volume / m_capacity;} 00065 00066 // Return true if the tank is empty, false otherwise. 00067 bool empty () const { return m_volume == 0.0; } 00068 }; 00069 } 00070 00071 #endif // !_FUEL_TANK_H_
1.4.6