Overrode print method according to problem specifications.