Added a check for valid rank in the Card class.