Package exercise3.exercise3_10

Examples of exercise3.exercise3_10.LinkedList


    final String OWNER = "Kubota";
    Vehicle[] vehicles = new Vehicle[VEHICLE_NUM];
   
    
    for(int i = 0; i < vehicles.length; i++) {
      vehicles[i] = new Vehicle();
      vehicles[i].setOwner(OWNER);
      vehicles[i].changeSpeed(Math.random() * i);
      vehicles[i].setDirection(Math.random() * i);
    }
   
    LinkedListImpl<Vehicle> startNode = new LinkedListImpl<Vehicle>(vehicles[0]);
   
    LinkedListImpl<Vehicle> node = startNode;
    for(int i = 1; i < vehicles.length; i++) {
      node.setNext(vehicles[i]);
      node = node.next;
    }
   
    LinkedListImpl<Vehicle> cloned = startNode.clone();
    ((Vehicle)cloned.next.value).setOwner("CHANGE");
    cloned.next.next.next = new LinkedListImpl<Vehicle>(new Vehicle("CHANGE"));
   
    System.out.println(startNode.toString());
    System.out.println(cloned.toString());
  }
View Full Code Here


    final String OWNER = "Kubota";
    Vehicle[] vehicles = new Vehicle[VEHICLE_NUM];
   
    
    for(int i = 0; i < vehicles.length; i++) {
      vehicles[i] = new Vehicle();
      vehicles[i].setOwner(OWNER);
      vehicles[i].changeSpeed(Math.random() * i);
      vehicles[i].setDirection(Math.random() * i);
    }
   
    LinkedList startNode = new LinkedList(vehicles[0]);
   
    LinkedList node = startNode;
    for(int i = 1; i < vehicles.length; i++) {
      node.setNext(new LinkedList(vehicles[i]));
      node = node.next;
    }
   
    LinkedList cloned = startNode.clone();
    ((Vehicle)cloned.next.value).setOwner("CHANGE");
    cloned.next.next.next = new LinkedList(new Vehicle("CHANGE"));
   
    System.out.println(startNode.toString());
    System.out.println(cloned.toString());
  }
View Full Code Here

TOP

Related Classes of exercise3.exercise3_10.LinkedList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.