尝试编译时出现Java错误

尝试编译时出现Java错误,java,compiler-errors,Java,Compiler Errors,我在一个作业中遇到了麻烦,在这个作业中,我们必须构造5个类来生成一个程序,该程序可以执行简单的计算和对二维几何体中表示的简单形状的操作 首先,它要求用户从三个选项中选择一个形状。 然后它会提示输入形状的详细信息。 通过给出X坐标和Y坐标来指定圆 它的中心,然后是它的半径。 三角形是通过给定X和Y坐标来指定的 三个角点中的每一个。 矩形是通过给定X和Y坐标来指定的 两个对角相对的角点 在此数据之后,将提示用户指定X偏移 和Y偏移量 程序创建指定的形状,也创建类似的形状, 其中,每个点已被X和Y偏移

我在一个作业中遇到了麻烦,在这个作业中,我们必须构造5个类来生成一个程序,该程序可以执行简单的计算和对二维几何体中表示的简单形状的操作

首先,它要求用户从三个选项中选择一个形状。 然后它会提示输入形状的详细信息。 通过给出X坐标和Y坐标来指定圆 它的中心,然后是它的半径。 三角形是通过给定X和Y坐标来指定的 三个角点中的每一个。 矩形是通过给定X和Y坐标来指定的 两个对角相对的角点

在此数据之后,将提示用户指定X偏移 和Y偏移量

程序创建指定的形状,也创建类似的形状, 其中,每个点已被X和Y偏移移动

然后,程序在标准输出上报告以下内容。 原始形状的细节-给出所有点 一,三,四,对于一个圆,它的半径。 形状的面积和周长。 改变形状的细节

这5类是变形、圆、三角形、点和矩形

我的代码如下:

长方形

三角

变形

除ShapeShift类外,所有类都会编译

我得到以下3个错误:

ShapeShift.java:78: error: cannot find symbol
        Circle shiftedCircle = originalCircle.shift(xShift, yShift);
 symbol:   method shift(double,double)

ShapeShift.java:96: error: cannot find symbol
        Triangle shiftedTriangle = originalTriangle.shift(xShift, yShift);
 symbol:   method shift(double,double)

ShapeShift.java:113: error: cannot find symbol
        Rectangle shiftedRectangle = originalRectangle.shift(xShift, yShift);
 symbol:   method shift(double,double)

我已经盯着这个看了这么久了,如果能有一双新的眼睛,我会非常感激的。提前感谢任何能提供帮助的人

在以下类中没有shift方法圆、三角形和矩形。

只有点类有shift方法。圆形、三角形和矩形没有。

正如我所看到的,问题是,在矩形、三角形和圆形类中没有声明任何名为shift的方法,但您正在尝试调用它


我能看到的唯一移位方法是Point类。

它几乎就是它所说的:圆、三角形和矩形没有移位方法。。。
public class Triangle
{

// Triangle, has 8 values including 2 shift values.

private final Point TrianglePoint1;
private final Point TrianglePoint2;
private final Point TrianglePoint3;

// Constructor Method

public Triangle(Point requiredTrianglePoint1,
                Point requiredTriagnlePoint2,
                Point requiredTrianglePoint3)
{
  TrianglePoint1 = requiredTrianglePoint1;
  TrianglePoint2 = requiredTriagnlePoint2;
  TrianglePoint3 = requiredTrianglePoint3;
}

public double perimeterOfTriangle()
{
  return (TrianglePoint1.distance(TrianglePoint2) +
          TrianglePoint2.distance(TrianglePoint3) +
          TrianglePoint3.distance(TrianglePoint1));
} // PerimeterTriangle

// Work and return the area of the triangle
public double areaOfTriangle()
{
  double semiPerimeter = (TrianglePoint1.distance(TrianglePoint2) +
                          TrianglePoint2.distance(TrianglePoint3) +
                          TrianglePoint3.distance(TrianglePoint1) / 2);

  return Math.sqrt(semiPerimeter *
                  (semiPerimeter - TrianglePoint1.distance(TrianglePoint2)) *
                  (semiPerimeter - TrianglePoint2.distance(TrianglePoint3)) *
                  (semiPerimeter - TrianglePoint3.distance(TrianglePoint1)));
 } // AreaTriangle
public class Circle
{

// Use the circle to find the centre and the radius.

private final Point centre;
private final double radius;

// Construct the two values

public Circle(Point requiredCentre, double requiredRadius)
{
  centre = requiredCentre;
  radius = requiredRadius;
}

public double areaOfCircle()
{
  return (Math.PI * (Math.pow(radius, 2)));
} // areaOfCircle

public double perimeterOfCircle()
{
  return (2 * Math.PI * radius);
} //Perimeter
}// Circle
public class Point
{
// Two Coordinate values for each point
  private final double coordinateX;
  private final double coordinateY;

// Construct the two values
  public Point(double requiredCoordinateX, double requiredCoordinateY)
{
  coordinateX = requiredCoordinateX;
  coordinateY = requiredCoordinateY;
}

// Get the X Coordinate
public double getXCoordinate()
{
  return coordinateX;
}

// Get Y Coordinate
public double getYCoordinate()
{
  return coordinateY;
}

// The layout, when demonstrating the two values.
public String toString()
{
  return "(" + coordinateX + "," + coordinateY + ")";
} // String

// Calculate the moved coordinates, when added to xShift and yShift
public Point shift(double xShift, double yShift)
{
  return new Point (coordinateX + xShift,
                    coordinateY + yShift);
} //movedPoint

// Calculate the distance between two points
public double distance(Point other)
{
  return Math.sqrt(Math.pow((coordinateX - other.coordinateX), 2) +
                   Math.pow((coordinateY - other.coordinateY), 2));
} // Distance calculated

} // Point
import java.util.Scanner;

public class ShapeShift
{
// A scanner to interact with the user.
  private static Scanner inputScanner = new Scanner(System.in);


// Helper method to read a point from the input.
  public static Point inputPoint(String prompt)
{
  System.out.print(prompt);
  double x = inputScanner.nextDouble();
  double y = inputScanner.nextDouble();
  return new Point(x, y);
} // inputPoint


// The X and Y amount to shift the first shape to get the second.
public static double xShift, yShift;

public ShapeShift(double shiftX, double shiftY)
{
  xShift = shiftX;
  yShift = shiftY;
}

 // Helper method to read the X and Y shifts.
private static void inputXYShifts()
{
  System.out.print("Enter the offset as X Y: ");
  double xShift = inputScanner.nextDouble();
  double yShift = inputScanner.nextDouble();
} // inputXYShifts


 // The main method.
public static void main(String[] args)
{
  // Obtain shape choice.
  System.out.print("Choose circle (1), triangle (2), rectangle (3): ");
  int shapeChoice = inputScanner.nextInt();

  // Process the shape based on the choice.
  switch (shapeChoice)
  {
    // Circle.
    case 1:
      Point centre = inputPoint("Enter the centre as X Y: ");
      System.out.print("Enter the radius: ");
      double radius = inputScanner.nextDouble();
      Circle originalCircle = new Circle(centre, radius);
      inputXYShifts();
      Circle shiftedCircle = originalCircle.shift(xShift, yShift);
      System.out.println();
      System.out.println(originalCircle);
      System.out.println("has area " + originalCircle.areaOfCircle()
                         + ", perimeter " 
                         + originalCircle.perimeterOfCircle());
      System.out.println("and when shifted by X offset " + xShift
                         + " and Y offset " + yShift + ", gives");
      System.out.println(shiftedCircle);
      break;

    // Triangle.
    case 2:
      Point pointA = inputPoint("Enter point A as X Y: ");
      Point pointB = inputPoint("Enter point B as X Y: ");
      Point pointC = inputPoint("Enter point C as X Y: ");
      Triangle originalTriangle = new Triangle(pointA, pointB, pointC);
      inputXYShifts();
      Triangle shiftedTriangle = originalTriangle.shift(xShift, yShift);
      System.out.println();
      System.out.println(originalTriangle);
      System.out.println("has area " + originalTriangle.areaOfTriangle()
                         + ", perimeter " 
                         + originalTriangle.perimeterOfTriangle());
      System.out.println("and when shifted by X offset " + xShift
                         + " and Y offset " + yShift + ", gives");
      System.out.println(shiftedTriangle);
      break;

    // Rectangle.
    case 3:
      Point diag1End1 = inputPoint("Enter one corner as X Y: ");
      Point diag1End2 = inputPoint("Enter opposite corner as X Y: ");
      Rectangle originalRectangle = new Rectangle(diag1End1, diag1End2);
      inputXYShifts();
      Rectangle shiftedRectangle = originalRectangle.shift(xShift, yShift);
      System.out.println();
      System.out.println(originalRectangle);
      System.out.println("has area " + originalRectangle.areaOfRectangle()
                         + ", perimeter " 
                         + originalRectangle.perimeterOfRectangle());
      System.out.println("and when shifted by X offset " + xShift
                         + " and Y offset " + yShift + ", gives");
      System.out.println(shiftedRectangle);
      break;

    // Bad choice.
    default:
      System.out.println("That wasn't 1, 2 or 3!");
      break;
  } // switch
} // main

} // class ShapeShift
ShapeShift.java:78: error: cannot find symbol
        Circle shiftedCircle = originalCircle.shift(xShift, yShift);
 symbol:   method shift(double,double)

ShapeShift.java:96: error: cannot find symbol
        Triangle shiftedTriangle = originalTriangle.shift(xShift, yShift);
 symbol:   method shift(double,double)

ShapeShift.java:113: error: cannot find symbol
        Rectangle shiftedRectangle = originalRectangle.shift(xShift, yShift);
 symbol:   method shift(double,double)