Hi, both of these methods involve removing and replacing the J,

 

public class Card {

 

   /**

    * String value that holds the suit of the card

    */

   private String suit;

 

   /**

    * String value that holds the rank of the card

    */

   private String rank;

 

   /**

    * int value that holds the point value.

    */

   private int pointValue;


 

  /**

    * Creates a new <code>Card</code> instance.

    *

    * @param cardRank  a <code>String</code> value

    *              containing the rank of the card

    * @param cardSuit  a <code>String</code> value

    *              containing the suit of the card

    * @param cardPointValue an <code>int</code> value

    *              containing the point value of the card

    */

   public Card(String cardRank, String cardSuit, int cardPointValue)

   {

       rank = cardRank;

       suit = cardSuit;

       pointValue = cardPointValue;

   }


 

   /**

    * Accesses this <code>Card's</code> suit.

    * @return this <code>Card's</code> suit.

    */

   public String suit()

   {

       return suit;

  }

 

  /**

    * Accesses this <code>Card's</code> rank.

    * @return this <code>Card's</code> rank.

    */

   public String rank()

   {

       return rank;

   }

 

  /**

    * Accesses this <code>Card's</code> point value.

    * @return this <code>Card's</code> point value.

    */

   public int pointValue()

   {

       return pointValue;

   }

 

   /** Compare this card with the argument.

    * @param otherCard the other card to compare to this

    * @return true if the rank, suit, and point value of this card

    *          are equal to those of the argument;

    *     false otherwise.

    */

   public boolean matches(Card otherCard)

   {

       if(rank.equalsIgnoreCase(otherCard.rank()) && (suit.equalsIgnoreCase(otherCard.suit())) && (pointValue == otherCard.pointValue()))

       {

           return true;

       }

       else

       {

           return false;

       }

   }

 

   /**

    * Converts the rank, suit, and point value into a string in the format

    * "[Rank] of [Suit] (point value = [PointValue])".

    * This provides a useful way of printing the contents

    * of a <code>Deck</code> in an easily readable format or performing

    * other similar functions.

    *

    * @return a <code>String</code> containing the rank, suit,

    *     and point value of the card.

    */

   @Override

   public String toString()

   {

       return (rank + " of " + suit + " point value = " + pointValue);

   }

}

 

所有跟帖: 

please post where card[] was instantiated. -LiveInCanada2- 给 LiveInCanada2 发送悄悄话 (299 bytes) () 05/24/2018 postreply 13:41:37

1) I am not sure which method is causing the error, but I know i -cm930118- 给 cm930118 发送悄悄话 (0 bytes) () 05/24/2018 postreply 13:45:52

that the error occurs in one (or both) classes. #2. I tried yo -cm930118- 给 cm930118 发送悄悄话 (0 bytes) () 05/24/2018 postreply 14:02:45

请您先登陆,再发跟帖!