I am creating a program, and I would like to know the best practice for creating a class which defines different fuel types
For instance, I have the following class that I have written in python:
class Fuel(): def __init__(self, fuel_type, energy_density): self.fuel_type = fuel_type self.energy_density = energy_density def energy_output(): return energy_density*100
The fuel types can be gas, coal or oil, with energy densities of 35.7, 24.0 and 43.37 respectively.
These numbers won't change when used in the future. However, somebody may wish to add an additional fuel type through a data file.
I thought that maybe inheritance could work, by defining a sub-class for each fuel type, with the energy densities pre-defined. But this would create a number of different classes that weren't very different, and it would be more difficult for users to add a new fuel type.
Any help on best practice would be greatly appreciated.