changes
This commit is contained in:
		
							parent
							
								
									480b25bccc
								
							
						
					
					
						commit
						1de89b46d5
					
				
					 1 changed files with 29 additions and 3 deletions
				
			
		|  | @ -202,7 +202,24 @@ public class Path { | |||
|      */ | ||||
|     public boolean isValid() { | ||||
|         // TODO: | ||||
|         return false; | ||||
|         boolean res=true; | ||||
|         //it is empty | ||||
|         if (this.size()!=0 && !this.arcs.isEmpty()){ | ||||
|             //it contains a single node without arcs | ||||
|             Node deb=origin; | ||||
|             for (Arc ligne : arcs){ | ||||
|                 if (ligne.getOrigin().equals(deb)) { | ||||
|                     deb=ligne.getDestination(); | ||||
|                 } | ||||
|                 else { | ||||
|                     res=false; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|         //the first arc has for origin the origin of the path and, for two consecutive arcs, the destination of the first one is the origin of the second one. | ||||
|          | ||||
|         return res; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -214,7 +231,11 @@ public class Path { | |||
|      */ | ||||
|     public float getLength() { | ||||
|         // TODO: | ||||
|         return 0; | ||||
|         float res=0; | ||||
|         for (Arc ligne : arcs) { | ||||
|             res+=ligne.getLength(); | ||||
|         } | ||||
|         return res; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -242,7 +263,12 @@ public class Path { | |||
|      */ | ||||
|     public double getMinimumTravelTime() { | ||||
|         // TODO: | ||||
|         return 0; | ||||
|         double min=0.0; | ||||
|         for (Arc ligne : arcs ){ | ||||
|             min+=ligne.getMinimumTravelTime(); | ||||
|         } | ||||
| 
 | ||||
|         return min; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue