Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Cannot find symbol

$
0
0
Hi, I'm starting to work with the equals and copy class, but my main problem is this annoying error message, but I have no idea what it means... please help.
Hw10.java:26: cannot find symbol
symbol  : constructor Point(Point)
location: class Point
      p2 = new Point(p1);


This is my code:
import java.io.*;
import java.util.Scanner;
//////////////////////////////////////////////////////////////////////
class Hw10
{
//--------------------------------------------------------------------
   public static void main ( String [] args ) throws Exception
   {
      Point p1 = new Point(2.1,3.4);
      Point p2 = new Point(5.2,7.3);

      System.out.println();
      System.out.println("p1 is " + p1);
      System.out.println("p2 is " + p2);

      System.out.println();
      System.out.println("p1 == p2      -> " + (p1==p2));
      System.out.println("p1.equals(p2) -> " + p1.equals(p2));

      p2 = new Point(2.1 + 1e-6, 3.4 - 1e-6);

      System.out.println();
      System.out.println("p1 == p2      -> " + (p1==p2));
      System.out.println("p1.equals(p2) -> " + p1.equals(p2));

      p2 = new Point(p1);

      System.out.println();
      System.out.println("p1 == p2      -> " + (p1==p2));
      System.out.println("p1.equals(p2) -> " + p1.equals(p2));

      p2 = p1.copy();

      System.out.println();
      System.out.println("p1 == p2      -> " + (p1==p2));
      System.out.println("p1.equals(p2) -> " + p1.equals(p2));
   }
//--------------------------------------------------------------------
} // end class Hw10
//////////////////////////////////////////////////////////////////////
class Point
{
   private double x,y;
//--------------------------------------------------------------------
   public Point ( double x, double y )
   {
      this.x = x;
      this.y = y;
   }
//--------------------------------------------------------------------
   public boolean equals ( Point that )
   {
      if ( (y - x) < 0.000001 || (x - y) < 0.000001 )
         return true;
      return false;
   }
//--------------------------------------------------------------------
   public Point copy()
   {
      return new Point(x, y);
   }
   
   public String toString()
   {
      return "Point(" + x + "00, " + y + "00)";
   }
} // end class Point
//////////////////////////////////////////////////////////////////////


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>