前提・実現したいこと
Vertical の "isParallel" と "equals" を実装したいのですが、以下のエラーが発生します。
発生している問題・エラーメッセージ
Vertical.java:72: エラー: シンボルを見つけられません return this.a.getX() != that.a.getX(); ^ シンボル: 変数 a 場所: タイプLineの変数 that Vertical.java:85: エラー: シンボルを見つけられません return this.a == that.a.getX(); ^ シンボル: 変数 a 場所: タイプLineの変数 that エラー2個
該当のソースコード(Vertical)
Java
1public class Vertical implements Line { 2 3 private double x; 4 5 public Vertical(double x) { 6 this.x = x; 7 } 8 9 private DPoint a; 10 private DPoint b; 11 12 public Vertical(DPoint a, DPoint b) { 13 if (a == null || b == null) 14 throw new IllegalArgumentException(); 15 16 if (!(a.getX() == b.getX())) 17 throw new IllegalArgumentException(); 18 19 this.a = a; 20 this.b = b; 21 } 22 23 public double getM() { 24 throw new IllegalArgumentException(); 25 } 26 27 public double getB() { 28 throw new IllegalArgumentException(); 29 } 30 31 public boolean isHorizontal() { 32 return false; 33 } 34 35 public boolean isVertical() { 36 return true; 37 } 38 39 public DPoint atX(double x) { 40 throw new IllegalArgumentException(); 41 } 42 43 public DPoint yIntercept() { 44 throw new IllegalArgumentException(); 45 } 46 47 public DPoint xIntercept() { 48 return new DPointObj(this.x, 0); 49 } 50 51 public DPoint intersection(Line that) { 52 if (this.isParallel(that)) { 53 return null; 54 } else if (this.equals(that)) { 55 throw new UnsupportedOperationException(); 56 } else { 57 return new DPointObj(this.x, this.a.getY()); 58 } 59 } 60 61 public DPoint intersection(LineSeg that) { 62 if (!(a.getX() == b.getX())) { 63 return null; 64 } else if (a.getX() == b.getX()) { 65 throw new UnsupportedOperationException(); 66 } else { 67 return new DPointObj(this.x, this.a.getY()); 68 } 69 } 70 71 public boolean isParallel(Line that) { 72 return this.a.getX() != that.a.getX(); 73 } 74 75 public boolean equals(Object o) { 76 if (o == null) { 77 return false; 78 } 79 80 if (!(o instanceof Line)) { 81 return false; 82 } 83 84 Line that = (Line)o; 85 return this.a == that.a.getX(); 86 } 87 88}
補足情報
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/07/22 08:01