重复课?对象的类

时间:2014-09-23 01:31:37

标签: java class object methods shapes

我试图制作一个六边形,我在文件夹中有一个文件夹名称mObjects包含Project4Tester.java和Hexagon.java。当我编译这是我得到的错误

找到2个错误: 文件:/home/user/Desktop/mObjects/Hexagon.java [line:4] 错误:重复的类:mObjects.Hexagon

文件:/home/user/Desktop/mObjects/Project4Tester.java [line:3] 错误:无法访问Hexagon   糟糕的源文件:/home/cmehmen/Desktop/mObjects/Hexagon.java     文件不包含类Hexagon     请删除或确保它出现在源路径的正确子目录中。

这里有完整的程序,我还没有完成Hexagon,因为我无法获得正确的Proect4Tester格式。有人可以请告诉我为什么我一直得到一个重复的课程....并且项目4无法找到Hexagon类

Hexagon.java

package mObjects;
import java.awt.Point;
public class Hexagon{

    private Point point;
    private int sideLength; 

    public Hexagon(Point point, int sideLength){
    }

    public Hexagon(int x, int y, int sideLength){
    }

    public void setSideLength(int sideLength){
        this.sideLength = sideLength;
    }

    public int getSideLength(int sideLength){
        return sideLength;
    }

    public void setPoint(Point point){
        this.point = point;  
    }

    public void setPoint(int x, int y){ 
    }

    public Point getPoint(){
        return point;
    }

    public double getArea(){

    }

    public double getPeremiter(){
        return sideLength*6;
    }
}

Project4Tester.java

public  class  Project4Tester  {
    public  static  void  main(String  []  args)  {
        Hexagon  p1  =  new  Hexagon(1,2,3);
        Hexagon  p2  =  new  Hexagon(new  Point(4,5),4);
        Hexagon  p3  =  new  Hexagon(new  Point(4,5),6);

        if  (p1.getPerimeter()  !=  18  ||  p2.getPerimeter()  !=  24
                                        ||  p3.getPerimeter()  !=  36)
            System.err.println("Error  1:  Perimeter  not  correct");      

        if  (  (p1.getArea()  <  23.3  ||  p1.getArea()  >  23.4)  ||
               (p2.getArea()  <  41.5  ||  p2.getArea()  >  41.6)  ||
               (p3.getArea()  <  93.5  ||  p3.getArea()  >  93.6)  )
            System.err.println("Error  2:  Area  not  correct");

        if  (  p1.getSideLength()  !=  3  ||  p2.getSideLength()  !=  4  
                                          ||  p3.getSideLength()  !=  6  )
            System.err.println("Error  3:  getSideLength  not  correct");

        p1.setSideLength(10);
        p2.setSideLength(11);
        p3.setSideLength(12);

        if  (  p1.getSideLength()  !=  10  ||  p2.getSideLength()  !=  11  
                                           ||  p3.getSideLength()  !=  12  )
            System.err.println("Error  4:  setSideLength  not  correct");

        if  (  p1.getPoint().x  !=  1  ||  p2.getPoint().x  !=  4  
                                       ||  p3.getPoint().x  !=  4    )
            System.err.println("Error  5:  getPoint  not  correct");

        p1.setPoint(3,4);
        p2.setPoint(new  Point(5,5));

        if  (  p1.getPoint().x  !=  3  ||  p2.getPoint().x  !=  5  
                                       ||  p3.getPoint().x  !=  4    )
            System.err.println("Error  6:  setPoint  not  correct");

        System.out.println("If  you  have  reached  this  point  with  no  errors  then  your  Hexagonclass  has  passed  the  pass-­‐off.");
}//end  main
}//end  class

我无法更改Project4Tester.java中的任何内容

0 个答案:

没有答案