What are the parts of a battery and how do they function?