posX не может быть разрешен или не является полем
Вот мой код:
Основной класс:
Код: Выделить всё
List GarbageList = new List();
void removeGarbage(int x,int y){
if(GarbageList.head != null && GarbageList.head.data.posX==x && GarbageList.head.data.posY==y){
GarbageList.head = GarbageList.head.head;
} else{
Node end = GarbageList.head;
while (end.next != null) {
if(end.next.data.posX==x && end.next.data.posY==y){
if(end.next.next != null){
end.next = end.next.next;
} else{
end.next = null;
}
}
end = end.next;
}
}
}
Код: Выделить всё
class Garbage{
int type;
int value;
int posX, posY;
PImage sprite;
/methods
.
.
.
}
Код: Выделить всё
class Node {
T data;
Node next;
Node(T data) {
this.data = data;
this.next = null;
}
}
Код: Выделить всё
class List {
Node head;
void add(T data) {
Node newNode = new Node(data);
if (head == null) {
head = newNode;
} else {
Node end = head;
while (end.next != null) {
end = end.next;
}
end.next = newNode;
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... ot-a-field
Мобильная версия