Пример #1
0
 /** Handles load setting */
 public static void runL() {
   System.out.println("Enter the product name: ");
   String n = input.nextLine();
   System.out.println("Enter the product weight in tons: ");
   double w = input.nextDouble();
   System.out.print("Enter the value in dollars: ");
   double v = input.nextDouble();
   System.out.print("Is the product dangerous? (Y/N)");
   String d = input.nextLine();
   boolean b = false;
   if (d.equals("Y")) b = true;
   list.getCursorData().setProductLoad(new ProductLoad(n, w, v, b));
   list.setWeight(list.getWeight() + w);
   list.setValue(list.getValue() + v);
 }
Пример #2
0
 /** Handles cursor backward */
 public static void runB() {
   try {
     list.cursorBackward();
     System.out.println("Cursor successfully moved backward.");
   } catch (NullPointerException e) {
     System.out.println("Can't move cursor backward");
   }
 }
Пример #3
0
  /** Handles train car insertion */
  public static void runI() {
    System.out.println("Enter car length in meters: ");
    double l = input.nextDouble();
    System.out.println("Enter car weight in tons: ");
    double w = input.nextDouble();

    list.insert(new TrainCar(l, w, new ProductLoad()));

    System.out.println("New train car " + l + "meters and " + w + "tons inserted into train.");
  }
Пример #4
0
 /** Handles train car removal */
 public static void runR() {
   try {
     TrainCar temp = list.removeCursor();
     System.out.println(
         "Car successully unlinked. The following load has been removed from the train:\n"
             + "Name      Weight (t)     Value ($)   Dangerous"
             + "===================================================");
     System.out.println(
         String.format(
             "%-14s%-15s%-12s%-9s",
             temp.getProductLoad().getName(),
             temp.getProductLoad().getWeight(),
             temp.getProductLoad().getValue(),
             temp.getProductLoad().getDangerous()));
   } catch (NullPointerException e) {
     System.out.println("Could not remove train car.");
   }
 }
Пример #5
0
 /** Handles danger removal */
 public static void runD() {
   list.removeDangerousCars();
   System.out.println("Dangerous cars successfully removed from the train.\n");
 }
Пример #6
0
 /** Handles manifest display */
 public static void runM() {
   list.printManifest();
 }
Пример #7
0
 /** Handles train display */
 public static void runT() {
   System.out.println(list.toString());
 }
Пример #8
0
 /** Handles product search */
 public static void runS() {
   System.out.println("Enter the product name");
   String n = input.nextLine();
   list.findProduct(n);
 }