発生している問題・エラーメッセージ
CardObj.java:33: エラー: シンボルを見つけられません Card.that = (Card)o; ^ シンボル: 変数 that 場所: インタフェース Card CardObj.java:35: エラー: シンボルを見つけられません return r.equals(that.getR()) && s.equals(that.getS()); ^ シンボル: 変数 that 場所: クラス CardObj CardObj.java:35: エラー: シンボルを見つけられません return r.equals(that.getR()) && s.equals(that.getS()); ^ シンボル: 変数 that 場所: クラス CardObj エラー3個
CardObj
Java
1public class CardObj implements Card { 2 3 private Rank r; 4 private Suit s; 5 6 public CardObj(Rank r, Suit s) { 7 if (r == null || s == null) { 8 throw new IllegalArgumentException(); 9 } 10 this.r = r; 11 this.s = s; 12 } 13 14 public Rank getRank() { 15 return this.r; 16 } 17 18 public Suit getSuit() { 19 return this.s; 20 } 21 22 public boolean isJoker() { 23 return false; 24 } 25 26 public boolean equals(Object o) { 27 if (o == null) 28 return false; 29 30 if (!(o instanceof Card)) 31 return false; 32 33 Card.that = (Card)o; 34 35 return r.equals(that.getR()) && s.equals(that.getS()); 36 } 37 38 public String toString() { 39 return r + "of" + s; 40 } 41 42}
Card
Java
1enum Suit { 2 DIAMONDS, CLUBS, HEARTS, SPADES 3} 4 5enum Rank { 6 ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING 7} 8 9public interface Card { 10 public Rank getRank(); 11 public Suit getSuit(); 12 public boolean isJoker(); 13 // the following are not named in interfaces, typically, since they're assumed 14 // public boolean equals(Object o); 15 // public String toString(); 16}
どうすれば、thatを問題なく使えるのでしょうか?よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/07/21 20:05