Explain the underlying principle and working of an electric generator by drawing a labelled diagram. What is the function of brushes?