Java(kareltherobot)问题

Java(kareltherobot)问题,java,karel,Java,Karel,我目前在高中的AP计算机科学课上。我们正在使用“kareltherobot”包用Java编写代码。以下是说明: 在这个实验室里,我们的机器人会像roomba一样工作。它会接收房间里所有的传呼机。它将在执行任务时跟踪信息。它必须清理房间里的每个地方。必须提示用户清洁房间(读取世界文件)以及机器人初始状态的位置和方向 要向用户报告的信息: •房间面积 •桩的数量 •传呼机总数 •最大数量的传呼机 •最大桩的位置(相对位置) •平均桩号 •脏污百分比(桩/面积) 我提供了一个模板和一个测试世界。因为我

我目前在高中的AP计算机科学课上。我们正在使用“kareltherobot”包用Java编写代码。以下是说明: 在这个实验室里,我们的机器人会像roomba一样工作。它会接收房间里所有的传呼机。它将在执行任务时跟踪信息。它必须清理房间里的每个地方。必须提示用户清洁房间(读取世界文件)以及机器人初始状态的位置和方向

要向用户报告的信息:

•房间面积

•桩的数量

•传呼机总数

•最大数量的传呼机

•最大桩的位置(相对位置)

•平均桩号

•脏污百分比(桩/面积)

我提供了一个模板和一个测试世界。因为我们正处于学习编程和测试的初始阶段,所以我提供了测试世界。考虑可能会破坏代码的测试用例,并尝试在开发过程中测试这些情况是一个好主意。 这是我目前的代码。我的问题是我能让机器人去东南角。我试图让它去那里,然后让它移动过来,并使用方法clean row。这样它就可以一行一行地清洁每一行。有人能帮我吗

import java.util.Scanner;

import javax.swing.JOptionPane;

import kareltherobot.*;


public class Driver implements Directions{
    public static int locationx2;
    public static int locationy2;
    public static String direction;
    Direction direction2;
    int beeperspicked;

    Robot r ;
    /**
     * @param args
     */
    public static void main(String[] args) {
        // LEAVE THIS ALONE!!!!!!
        Driver d = new Driver();
        d.getInfo();
        d.cleanRoom();
        //d.printResults();
    }

    private void printResults() {
        // A bunch of System.out.prints go here
        JOptionPane.showMessageDialog(null, "Number of piles was" + );
        JOptionPane.showMessageDialog(null, "Area of room was" + );
        JOptionPane.showMessageDialog(null, "Number of beepers was" + beeperspicked );
        JOptionPane.showMessageDialog(null, "Largest pile of beepers was" + );
        JOptionPane.showMessageDialog(null, "Location of the largest pile was" + );
        JOptionPane.showMessageDialog(null, "Average pile size was" + );
        JOptionPane.showMessageDialog(null, "The percent dirty was" + );
    }

    private void cleanRoom() {
        // all the code that cleans and counts goes here
        // obviously, lots more here
        r= new Robot(locationy2,locationx2,direction2,0);
        beeperspicked= 0;
        int loop= 2;
        while (r.frontIsClear()){
            while (!r.facingEast()){
                r.turnLeft(); }
            while (r.facingEast()){
                r.move(); }
        }
        while (!r.frontIsClear()){
            r.turnLeft();
        }

















        while (loop==0){
            cleanRow();
        }

    }   




    private void cleanRow() {
        while (r.nextToABeeper()== true) {
               r.pickBeeper();
               beeperspicked++;}
        while (r.frontIsClear()== true)  {
                r.move(); }
        while (!r.frontIsClear()){
            r.turnLeft();
            r.turnLeft();
        }
        }

    private void getInfo() {
        // this method acquires the starting street, avenue and direction
        // of the robot from the user.  Also it inputs the name of the world
        // file.  It then opens the world file and creates the robot
        String worldname = JOptionPane.showInputDialog("World Name?");
        String locationx = JOptionPane.showInputDialog("X Coordinate?");
        locationx2 = Integer.parseInt(locationx);
        String locationy = JOptionPane.showInputDialog("Y Coordinate?");
        locationy2 = Integer.parseInt(locationy);
        String direction = JOptionPane.showInputDialog("Direction to face?");
        if (direction.equals("North")) {
            direction2= North;
        }
        if (direction.equals("East")) {
            direction2= East;
        }
        if (direction.equals("West")) {
            direction2= West;
        }
        if (direction.equals("South")) {
            direction2= South;
        }
        else
        {
            direction2= North;
        }

        String wrldName = worldname + ".wld";



        World.readWorld(wrldName);
        //set world size?
        World.setVisible(true);
        World.setDelay(20);
    }

}

到底是什么问题?i、 你遇到了什么样的错误?到底是什么问题?i、 e.你会遇到什么样的错误?