Commits

David Lin  committed ad30483

Add test102

  • Participants
  • Parent commits 0194f44

Comments (0)

Files changed (1)

File src/Main.java

     for(Edge ed : result)
       System.out.println(ed.toString());
     
+    System.out.println("");
+    
     sp.setEdgeComparator(new EdgeCostComparator());
     result = sp.compute(from, to, pak);
     System.out.println("result for least cost:");
     
   }
   
+  public static void test102()
+  {
+    ShortestPath sp = new ShortestPath();
+    Map<String, Location> locations = new HashMap<String, Location>();
+    
+    locations.put("A", new City("A"));
+    locations.put("B", new City("B"));
+    locations.put("C", new City("C"));
+    
+    AbstractEdge e;
+    e = new Road(locations.get("A"), locations.get("B"));
+    e.setTime(10);
+    sp.addEdge(e);
+    
+    e = new Ship(locations.get("A"), locations.get("B"));
+    e.setTime(12);
+    sp.addEdge(new Freeze(e));
+    
+    e = new Road(locations.get("B"), locations.get("C"));
+    e.setTime(14);
+    sp.addEdge(new Freeze(e));
+    
+    e = new Road(locations.get("B"), locations.get("C"));
+    e.setTime(5);
+    sp.addEdge(e);
+    
+    e = new Road(locations.get("C"), locations.get("C"));
+    e.setTime(2);
+    sp.addEdge(e);
+    
+    e = new Road(locations.get("C"), locations.get("B"));
+    e.setTime(1);
+    sp.addEdge(e);
+    
+    Location from, to;
+    Package pak;
+    List<Edge> result;
+    
+    from = locations.get("A");
+    to = locations.get("C");
+    
+    System.out.println("result for NormalPackage: ");
+    
+    pak = new NormalPackage(10);
+    result = sp.compute(from, to, pak);
+    for(Edge ed : result)
+      System.out.println(ed.toString());
+    
+    System.out.println("");
+    
+    System.out.println("result for Meat: ");
+    
+    pak = new Meat(10);
+    result = sp.compute(from, to, pak);
+    for(Edge ed : result)
+      System.out.println(ed.toString());
+    
+  }
+  
+  ////////////////////////////////////////////////////////
+  
+  public static void test103()
+  {
+    
+  }
+  
+  ////////////////////////////////////////////////////////
+  
   // app main
   public static void main(String args[])
   {
     System.out.println("==== Test 101 ====");
     test101();
     System.out.println("==================");
+    
+    System.out.println("==== Test 102 ====");
+    test102();
+    System.out.println("==================");
+    
   }
   
 }