added ex2.3, added toString method for ex2.2