Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. public static Path[] CalculateFinalPoints(Point startPoint, int remainingDistance)//not forget to change PN!!
  2.     {
  3.         List <Path> pathsList = new ArrayList<Path>();
  4.         for (int i=0;i<startPoint.GetPN();i++)
  5.         {
  6.             Path tempPath = startPoint.GetPath(i);
  7.             if (tempPath.GetLength()<=remainingDistance)
  8.             {
  9.                 Path[] tempArray = CalculateFinalPoints(points[tempPath.GetFinishPoint()], remainingDistance-tempPath.GetLength());
  10.                 for (int j=0;j<tempArray.length;j++)
  11.                 {
  12.                     pathsList.add(new Path(startPoint.GetNumber(), tempArray[j].GetFinishPoint(), tempPath.GetLength()+tempArray[j].GetLength(), tempPath.GetPrice()+tempArray[j].GetPrice()));
  13.                 }
  14.             }
  15.         }
  16.         return convertPathListToArray(pathsList);
  17.     }
  18.     public static Path[] convertPathListToArray(List<Path> list)
  19.     {
  20.         Path[] toReturn = new Path[list.size()];
  21.         for (int i=0;i<list.size();i++)
  22.         {
  23.             toReturn[i]=list.get(i);
  24.         }
  25.         return toReturn;
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement