implement Cost class