Форум программистов, компьютерный форум, киберфорум
Java SE (J2SE)
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.53/15: Рейтинг темы: голосов - 15, средняя оценка - 4.53
0 / 0 / 0
Регистрация: 24.05.2018
Сообщений: 16
1

Не пойму что за ошибка?

27.05.2018, 15:52. Показов 2959. Ответов 8
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
пишет
Compilation error
Main.java:90: error: cannot find symbol
moveRobot(robot, toX, toY);
^
symbol: method moveRobot(Main.Robot,int,int)
location: class Main
Main.java:188: error: Illegal static declaration in inner class Main.Robot
public static void moveRobot(Robot robot, int toX, int toY) {
^
modifier 'static' is only allowed in constant variable declarations
2 errors


Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
public class Robot
{
        private int x;
        private int y;
        private Direction direction;
 
        public Robot(int x, int y, Direction direction) {
            this.x = x;
            this.y = y;
            this.direction = direction;
        }
 
        public Direction getDirection() {
            return direction;
        }
 
        public int getX() {
            return x;
        }
 
        public int getY() {
            return y;
        }
 
        public void turnLeft() {
            switch (direction) {
                case DOWN:
                    System.out.println("turning left");
                    direction = Direction.RIGHT;
                    break;
                case LEFT:
                    System.out.println("turning left");
                    direction = Direction.DOWN;
                    break;
                case RIGHT:
                    System.out.println("turning left");
                    direction = Direction.UP;
                    break;
                case UP:
                    System.out.println("turning left");
                    direction = Direction.LEFT;
                    break;
                default:
                    break;
            }
        }
 
        public void turnRight() {
            switch (direction) {
                case DOWN:
                    System.out.println("turning right");
                    direction = Direction.LEFT;
                    break;
                case LEFT:
                    System.out.println("turning right");
                    direction = Direction.UP;
                    break;
                case RIGHT:
                    System.out.println("turning right");
                    direction = Direction.DOWN;
                    break;
                case UP:
                    System.out.println("turning right");
                    direction = Direction.RIGHT;
                    break;
                default:
                    break;
            }
        }
 
        public void stepForward() {
            switch (direction) {
                case DOWN:
                    --y;
                    System.out.println("moving down");
                    break;
                case LEFT:
                    --x;
                    System.out.println("moving left");
                    break;
                case RIGHT:
                    ++x;
                    System.out.println("moving right");
                    break;
                case UP:
                    System.out.println("moving up");
                    ++y;
                    break;
                default:
                    break;
            }
        }
 
        public static void moveRobot(Robot robot, int toX, int toY) {
 
            while (( robot.getX()!= toX) | ( robot.getY()!= toY))
            {
                if (toX > robot.getX())
                {
                    while (robot.getDirection()!= Direction.RIGHT)
                    {
                        robot.turnRight();
                    }
                    while (robot.getX()!= toX) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getX());
                }
                else if (toX < robot.getX())
                {
                    while (robot.getDirection () != Direction.LEFT)
                    {
                        robot.turnRight();
                    }
                    while (robot.getX()!= toX) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getX());
                }
                if (toY > robot.getY())
                {
                    while (robot.getDirection () != Direction.UP)
                    {
                        robot.turnRight();
                    }
                    while (robot.getY()!= toY) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getY());
                }
                if (toY < robot.getY())
                {
                    while (robot.getDirection () != Direction.DOWN)
                    {
                        robot.turnRight();
                    }
 
                    while (robot.getY()!= toY) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getY());
                }
            }
            System.out.println("Robot in position X = " +robot.getX()+ " Y=" + robot.getY());
 
        }
}
не судите строго.
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
27.05.2018, 15:52
Ответы с готовыми решениями:

Не пойму что за ошибка
00:14:00,760 INFO (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem...

Не пойму что за ошибка
Не пойму что за ошибка в консольном окне домино без конца появляется ошибка показанная в рисунке

Не пойму, что за ошибка
пожайлуста, помогите, то никак не могу понять почемуто, если писать сценарий таким образом: ...

Что то я не пойму почему ошибка
ошибка такая ('Not enough actual parameters') в строчке FFilterDlg:=TFilterDlg.Create(Self);...

8
Am I evil? Yes, I am!
Эксперт PythonЭксперт Java
17573 / 10326 / 2820
Регистрация: 21.10.2017
Сообщений: 22,388
27.05.2018, 16:08 2
MakarovDs, static убери из метода moveRobot()
0
0 / 0 / 0
Регистрация: 24.05.2018
Сообщений: 16
27.05.2018, 16:19  [ТС] 3
хаххха
Compilation error
Main.java:90: error: cannot find symbol
moveRobot(robot, toX, toY);
^
symbol: method moveRobot(Main.Robot,int,int)
location: class Main
1 error
0
Am I evil? Yes, I am!
Эксперт PythonЭксперт Java
17573 / 10326 / 2820
Регистрация: 21.10.2017
Сообщений: 22,388
27.05.2018, 16:20 4
ВЕСЬ код выложи
0
0 / 0 / 0
Регистрация: 24.05.2018
Сообщений: 16
27.05.2018, 16:26  [ТС] 5
я выложил весь код

Добавлено через 51 секунду
я задание делаю вот https://stepik.org/lesson/12766/step/12?unit=3114
0
Am I evil? Yes, I am!
Эксперт PythonЭксперт Java
17573 / 10326 / 2820
Регистрация: 21.10.2017
Сообщений: 22,388
27.05.2018, 16:29 6
Цитата Сообщение от MakarovDs Посмотреть сообщение
я задание делаю вот
молодец! Весь свой код покажи, как ты пытаешься запустить/протестировать этот класс.
0
0 / 0 / 0
Регистрация: 24.05.2018
Сообщений: 16
27.05.2018, 16:34  [ТС] 7
ну это ит есть весь код
0
Am I evil? Yes, I am!
Эксперт PythonЭксперт Java
17573 / 10326 / 2820
Регистрация: 21.10.2017
Сообщений: 22,388
27.05.2018, 16:54 8
Тогда КАК ты пытаешься его запустить? Нужно создать объект класса робот и вызывать у него соответствующие методы...


Добавлено через 1 минуту
Если бы ты дошел до этого урока на степике последовательно, вопроса бы не было...

Добавлено через 13 минут
MakarovDs, где psvm?
0
0 / 0 / 0
Регистрация: 12.07.2016
Сообщений: 1
29.11.2018, 19:42 9
Сделала так:
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
public void moveRobot(Robot robot, int toX, int toY) {
 
            while (( robot.getX()!= toX) | ( robot.getY()!= toY))
            {
                if (toX > robot.getX())
                {
                    while (robot.getDirection()!= Direction.RIGHT)
                    {
                        robot.turnRight();
                    }
                    while (robot.getX()!= toX) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getX());
                }
                else if (toX < robot.getX())
                {
                    while (robot.getDirection () != Direction.LEFT)
                    {
                        robot.turnRight();
                    }
                    while (robot.getX()!= toX) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getX());
                }
                if (toY > robot.getY())
                {
                    while (robot.getDirection () != Direction.UP)
                    {
                        robot.turnRight();
                    }
                    while (robot.getY()!= toY) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getY());
                }
                if (toY < robot.getY())
                {
                    while (robot.getDirection () != Direction.DOWN)
                    {
                        robot.turnRight();
                    }
 
                    while (robot.getY()!= toY) {
                        robot.stepForward();
                    }
                    System.out.println(robot.getY());
            }
            System.out.println("Robot in position X = " +robot.getX()+ " Y=" + robot.getY());
 
        }
}
 
public class Robot {
        private int x;
        private int y;
        private Direction direction;
 
        public Robot(int x, int y, Direction direction) {
            this.x = x;
            this.y = y;
            this.direction = direction;
        }
 
        public Direction getDirection() {
            return direction;
        }
 
        public int getX() {
            return x;
        }
 
        public int getY() {
            return y;
        }
 
        public void turnLeft() {
            switch (direction) {
                case DOWN:
                    System.out.println("turning left");
                    direction = Direction.RIGHT;
                    break;
                case LEFT:
                    System.out.println("turning left");
                    direction = Direction.DOWN;
                    break;
                case RIGHT:
                    System.out.println("turning left");
                    direction = Direction.UP;
                    break;
                case UP:
                    System.out.println("turning left");
                    direction = Direction.LEFT;
                    break;
                default:
                    break;
            }
        }
 
        public void turnRight() {
            switch (direction) {
                case DOWN:
                    System.out.println("turning right");
                    direction = Direction.LEFT;
                    break;
                case LEFT:
                    System.out.println("turning right");
                    direction = Direction.UP;
                    break;
                case RIGHT:
                    System.out.println("turning right");
                    direction = Direction.DOWN;
                    break;
                case UP:
                    System.out.println("turning right");
                    direction = Direction.RIGHT;
                    break;
                default:
                    break;
            }
        }
 
        public void stepForward() {
            switch (direction) {
                case DOWN:
                    --y;
                    System.out.println("moving down");
                    break;
                case LEFT:
                    --x;
                    System.out.println("moving left");
                    break;
                case RIGHT:
                    ++x;
                    System.out.println("moving right");
                    break;
                case UP:
                    System.out.println("moving up");
                    ++y;
                    break;
                default:
                    break;
            }
        }
}
Удачи
0
29.11.2018, 19:42
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
29.11.2018, 19:42
Помогаю со студенческими работами здесь

не пойму что это за ошибка(
помогите пожалуйста! я нашла программу подходящюю мне по заданию, добавила в нее необходимые...

Ошибка не пойму что не так
#include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;conio.h&gt; using namespace std; int main()...

Сломал голову... а что за ошибка - не пойму
Подскажите пож-та, о чем говорит эта ошибка: MySQL result resource in...

Не пойму что значит эта ошибка
Скажите, пожалуйста, что это за ошибка. Никак не могу разобраться :wall:. Заранее большое спасибо!


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
9
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru