Пример #1
0
  private static void test1() {

    for (int i = 0; i < 5; i++) {
      testGarden.addFruit(i, "Fruit " + i);
    }
    testGarden.printList(testGarden.fruits);
    for (int i = 0; i < 5; i++) {
      testGarden.addVegetable(i, "Vegetable " + i);
    }
    testGarden.printList(testGarden.vegetables);

    testGarden.addFruit(7, "New Fruit 0");
    testGarden.printList(testGarden.fruits);

    testGarden.addVegetable(3, "New Vegetable 0");
    testGarden.addVegetable(5, "New Vegetable 1");
    testGarden.printList(testGarden.vegetables);

    testGarden.removeFruit(10);
    testGarden.printList(testGarden.fruits);

    testGarden.removeVegetable(3);
    testGarden.printList(testGarden.vegetables);

    testGarden.removeVegetable(6);
    testGarden.printList(testGarden.vegetables);
  }
Пример #2
0
 @Override
 public void run() {
   for (int i = 0; i < 100; i++) {
     testGarden.addFruit(0, "Fruit " + i);
     try {
       Thread.sleep(500);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
 }