Bu kodla mücadele ediyorum. Eclipse, startnode türünü değiştirmemeyi ve nonode nodu değiştirmemi söylüyor. Bunu yaptım ve hiç bir yolum yok. Birisi bana ne yapmam gerektiğini açıklayabilir, çünkü en kısa yolu almak zordur. Mümkünse bana hatalarımı ve nasıl düzeltileceğini göster. şimdiden teşekkürlergetShortestPath; Bu kodu nasıl düzeltebilirim?
public List<Coordinate> getShortestPath(Coordinate start, Coordinate end) {
Coordinate start = board.get(start.getRow()).get(start.getCol()); **eclipse ask me to change type of start to node**
Coordinate end = board.get(end.getRow()).get(end.getCol());
tutulma yanlış olduğunu tam olarak ne olduğunu anlatıyor başlangıç türünü değiştirmek için bana sorup da sonu (Eclipse aracılığıyla)
List<Coordinate> dispenser = new LinkedList<Coordinate>();
dispenser.add(start);
Map<Coordinate, Coordinate> predecessors = new HashMap<Coordinate, Coordinate>();
while (!dispenser.isEmpty()){
Coordinate current = dispenser.remove(0);
if(current == end){
break;
}//end of if
for(Coordinate n : getNeighbors(current)){
if(!predecessors.containsKey(n)){
predecessors.put(n, current);
dispenser.add(n);
return constructPath(predecessors, start, end);
}//end of while
List<Coordinate> path = new LinkedList<Coordinate>();
if (predecessors.containsKey(endNode)) {
Coordinate currNode = endNode;
while (currNode != startNode) {
path.add(0, currNode);
currNode = predecessors.get(currNode);
}//end of while
path.add(0, startNode);
}//end of if
return path;
}
List<Coordinate> shortest = new LinkedList<Coordinate>();
for (Node p: path){
shortest.add(((coordinate) p).getCoordinate()); **eclipse says cannot cast from node to coordinate** I am not so good with java, I need help *
}
return shortest;
}
'startNode' ve' endNode' için neyi ve nasıl bildirdiniz? Eclipse'in bu önemli bilgi parçası olmadan sana ne anlatmaya çalıştığını anlayamıyorum. Yanıtınız için – ajb
teşekkürler. eclipse düğümün başlangıcında değişiklik türünü belirtir: Koordinat başlangıç = board.get (start.getRow()). (start.getCol()); \t Koordinat sonu = board.get (end.getRow()). (End.getCol()); – adim2
Ne 'tahta' gibi görünüyor bilmiyorum. Hala sana yardım edemem. – ajb