java - Mac 上的 Eclipse 与 Windows 上的 Eclipse 比较?

标签 java

基本上,在我的大学,我们有一个 Finch 机器人来配合工作并帮助我们发展 Java 编程技能。不过,我有一个小问题。 Uni 使用 Windows 机器,我使用 Mac,基本上我们已经获得了预先编写的代码来测试我们的 Finch 机器人。当我在 WIndows 机器中复制并粘贴代码时,Eclipse 没有给我任何错误,我可以继续测试机器人,但是当我在 Mac 上尝试相同的操作时,我收到 30 个错误!我不知道我做错了什么。

这是代码(我已将错误粘贴在代码下方):

import java.util.Random;
import javax.swing.JOptionPane;
import edu.cmu.ri.createlab.terk.robot.finch.Finch;

public class DoesMyFinchWork 
   {
//This value is the time for most of the tests in milliseconds, 1000 = 1 second
//Change this value if the tests are too long or short
final private static int testtime = 5000;
//This is the Finch object
private static Finch myf = null;
//This is the starting point of the testing program
public static void main(String args[]) 
{
    String s = "";
    //'myf' is the name of our Finch object
    //This will used throughout the program to control your Finch and report it's status  
    myf = new Finch();
    do
    {
        //Run the menu until quit or cancel is selected
        s = FinchMenu();
        if (s == "Light Test") RunLightTest(s);
        if (s == "Tilt Test") RunTiltTest(s);
        if (s == "Tap Test") RunTapTest(s);
        if (s == "Temperature Test") RunTemperatureTest(s);
        if (s == "Obstacle Test") RunObstacleTest(s);
        if (s == "Acceleration Test") RunAccelerationTest(s);
        if (s == "Left Wheel Test") RunLeftWheelTest(s);
        if (s == "Right Wheel Test") RunRightWheelTest(s);
        if (s == "Buzzer Test") RunBuzzerTest(s);
        if (s == "Nose Test") RunNoseTest(s);
    } while (s != "Quit"); 
    System.out.println("Exiting DoesMyFinchWork...");
    myf.quit();
}
//This creates the Finch menu
private static String FinchMenu()
{
    Object[] possibilities = {"Light Test", "Tilt Test","Tap Test","Temperature Test", "Obstacle Test","Acceleration Test","Left Wheel Test","Right Wheel Test","Buzzer Test","Nose Test","Quit"};
    String s = (String)JOptionPane.showInputDialog(null,"Dr Swift's Splendid Finch Test\n++++++++++++++++++++++++\nChoose a test from:\n\n","Week Zero Laboratory",JOptionPane.PLAIN_MESSAGE, null,possibilities,"Light Test");
    if (s == null || s.length() == 0) s = "Quit";
    return(s);
}
//Run the light sensor test
//Displays the left and then the right sensor output
private static void RunLightTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    long before = System.currentTimeMillis();
    while(System.currentTimeMillis() - before < testtime)
    {
        System.out.println(myf.getLeftLightSensor() + " " + myf.getRightLightSensor());
    }
}
//Run the Tilt Test
//Displays:
//1) Is the beak down?
//2) Is the beak up?
//3) Is the Finch level?
//4) Is the Finch upside down?
//5) Is the Finch's left wing down?
//6) Is the Finch's right wing down?
private static void RunTiltTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    long before = System.currentTimeMillis();
    while(System.currentTimeMillis() - before < testtime)
    {
        System.out.println(myf.isBeakDown() + " " + myf.isBeakUp() + " " + myf.isFinchLevel() + " " + myf.isFinchUpsideDown() + " " + myf.isLeftWingDown() + " " + myf.isRightWingDown());
    }
}
//Run the tap test
//Displays if the Finch has been tapped
private static void RunTapTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    long before = System.currentTimeMillis();
    while(System.currentTimeMillis() - before < testtime)
    {
        System.out.println(myf.isTapped());
    }
}
//Run the temperature test
//Displays the current temperature in degrees Celsius
private static void RunTemperatureTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    long before = System.currentTimeMillis();
    while(System.currentTimeMillis() - before < testtime)
    {
        System.out.println(myf.getTemperature());
    }
}
//Run the obstacle sensor test
//Displays if there is an obstacle left and right of the Finch
private static void RunObstacleTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    long before = System.currentTimeMillis();
    while(System.currentTimeMillis() - before < testtime)
    {
        System.out.println(myf.isObstacleLeftSide() + " " + myf.isObstacleRightSide());
    }
}
//Run the acceleration sensor test
//Displays is the Finch is being shaken, and then the acceleration in the X, Y and Z planes
private static void RunAccelerationTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    long before = System.currentTimeMillis();
    while(System.currentTimeMillis() - before < testtime)
    {
        System.out.println(myf.isShaken()+ " " + myf.getXAcceleration() + " " + myf.getYAcceleration()+ " " + myf.getZAcceleration());
    }
}
//Run the left wheel test
//Move the left wheel forward and backwards
private static void RunLeftWheelTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    myf.setWheelVelocities(255,0,testtime/2);
    myf.setWheelVelocities(-255,0,testtime/2);
}
//Run the right wheel test
//Move the right wheel forward and backwards
private static void RunRightWheelTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    myf.setWheelVelocities(0,255,testtime/2);
    myf.setWheelVelocities(0,-255,testtime/2);
}
//Sound the buzzer for a number of different frequencies
private static void RunBuzzerTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    for(int i=0;i<=5000;i+=10)
    {
        myf.buzz(i,10);
        long before = System.currentTimeMillis();
        while(System.currentTimeMillis() - before < 10)
        {
            //Do nothing...
        }
    }
}
//Flash the Finch's nose red, green and blue
//Then flash it randomly
private static void RunNoseTest(String s)
{
    System.out.println("\n"+"Running: "+s+"\n");
    for(int r=0;r<=255;r+=5)
    {
        myf.setLED(r,0,0,10);
    }
    for(int g=0;g<=255;g+=5)
    {
        myf.setLED(0,g,0,10);
    }
    for(int b=0;b<=255;b+=5)
    {
        myf.setLED(0,0,b,10);
    }
    Random rand = new Random();
    rand.setSeed(System.currentTimeMillis());
    for(int i=0;i<50;++i)
    {
        int r = Math.abs(rand.nextInt() % 255);
        int g = Math.abs(rand.nextInt() % 255);
        int b = Math.abs(rand.nextInt() % 255);
        myf.setLED(r,g,b,5);
    }
}

}

以下是一些错误(所有 30 个错误均表示“Finch 无法解析为类型”):

Description Resource    Path    Location    Type
Finch cannot be resolved to a type  DoesMyFinchWork.java    /DoesMyFinchWork/src    line 169    Java
Problem          
Finch cannot be resolved to a type  DoesMyFinchWork.java    /DoesMyFinchWork/src    line 165    Java   
Problem
Finch cannot be resolved to a type  DoesMyFinchWork.java    /DoesMyFinchWork/src    line 161    Java  
Problem
Finch cannot be resolved to a type  DoesMyFinchWork.java    /DoesMyFinchWork/src    line 146    Java

非常感谢您的帮助!

最佳答案

看起来 Windows 计算机已经完成了一些配置,以便它知道在哪里可以找到此 Finch 类,而您的 Mac 则不然。相当肯定,Windows 与 Mac 的问题在这里是转移注意力的:如果您找到另一台(未配置的)Windows 计算机,它就无法工作。

您可能需要下载一个包含 Finch 类的库,然后配置 Eclipse 来查找它。获取此信息的最佳位置可能是类笔记/网站。如果没有,那就问教授吧。

关于java - Mac 上的 Eclipse 与 Windows 上的 Eclipse 比较?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12731880/

相关文章:

java - 将 Jetty 8 升级到 Jetty 9

java - 无法在 logback 中关闭控制台日志记录

java - 在 JSON 字符串中插入节点

java InetAddress.getLocalHost();返回 127.0.0.1 ...如何获得真实 IP?

java - 经过训练的神经网络对所有评估行输出相同的结果

java - JUnit 返回错误,创建 URL 中定义的名称为 'sessionFactory' 的 bean

java - mediaplayer.isPlaying 始终为 false

java - Java中子线程如何向主线程(方法)发送连续的消息?

java - Comparable 接口(interface)前无接口(interface)词

java - 不幸的是,我的应用程序由于 nullPointerException 已停止工作