Class PARTICLE


class PARTICLE

-- A particle, which has an energy nad knows how to decay


inherit

   BASIC_IO 

creation 

   make

feature --  Anybody may create a particle

   make (e: REAL g: INTEGER) is
         -- Create the particle, give it its energy, decay it
      do
         energy := e
         generation := g
         decay
      end -- make

feature {NONE} -- Only particle itself knows how to decay and what energy it has

   decay is
         -- Decay the particle and divide the energy 1:2
         -- Stop, when the energy is less than 0.1
         -- Prit out the generation of stable particle
      local
         p1: PARTICLE
         p2: PARTICLE
      do
         if energy > 0.1 then
   	 !!p1.make (energy / 3., generation + 1)
   	 !!p2.make (2. * energy / 3., generation + 1)
         else
   	 put_string ("END: ")
   	 put_int (generation)
   	 put_string ("%N")
         end
      end -- decay

   energy : REAL 
         -- An energy of the particle

   generation : INTEGER 
         -- A generation of the particle

end -- class PARTICLE

J.H.11/12/94