对于Double

时间:2016-04-05 23:30:15

标签: java

在Eclipse中,它给出了错误,即类型Double的方法未定义,但返回值为Double。当我编译它时,它说它找不到符号getF

public Double getF()
{
    if (cof == 'c' || cof == 'C')
    {
        converted = (deg * 1.8) + 32;
        converted = Math.round(converted*10.0)/10.0;
        dConv = converted;
        return dConv;
    }

    dDeg = deg;
    return dDeg;

当我尝试使用getF方法时,我在此equals方法中得到错误。

public boolean equals(double degrees)
{
    test = degrees;
    dTest = test;
    if (this == dTest.getF())
    {
        return true;
    }

    return false;
}

我正在针对测试人员运行代码。这是其中一项测试:

     System.out.println("Test case 18: equals test 1.");
     System.out.println();
     t1.set(100, 'C');
     t2.set(212, 'F');
     System.out.println("T1 = 100 degrees C.");
     System.out.println("T2 = 212 degrees F.");
     System.out.println();
     System.out.println("Here are the two temperatures " + "converted to degrees C:");
     t1.writeC();
     t2.writeC();
     System.out.println();
     System.out.println("Verify results: should be true.");
     System.out.println();
     System.out.println(t1.equals(t2));
     System.out.println();
     System.out.println("Hit 'y' to continue.");
     junk = scan.nextLine();
     System.out.println();

这是构造函数:

public Temperature (double degrees, char type)
{
    deg = degrees;
    cof = type;
}

0 个答案:

没有答案