예제 #1
0
  public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("expert006/expert006.xml");

    Car car = context.getBean("car", Car.class);

    System.out.println(car.getTireBrand());
  }
예제 #2
0
  @Test
  public void findCustomerWithCar() {
    assertTrue(car1.getAvailable());
    assertTrue(car2.getAvailable());
    assertTrue(car3.getAvailable());

    manager.rentCarToCustomer(
        car1, customer1, Date.valueOf("2012-03-21"), Date.valueOf("2012-03-31"));

    assertEquals(customer1, manager.findCustomerWithCar(car1));
    assertCustomerDeepEquals(customer1, manager.findCustomerWithCar(car1));
    assertTrue(car2.getAvailable());
    assertTrue(car3.getAvailable());

    try {
      manager.findCustomerWithCar(null);
      fail();
    } catch (IllegalArgumentException e) {
    }
    try {
      manager.findCustomerWithCar(carWithoutID);
      fail();
    } catch (IllegalArgumentException e) {
    }
  }
예제 #3
0
  public static void main(String[] args) {
    Car Pride = new Car("프라이드", 2005, "파랑");
    Pride.OutInfo();

    Car.CarName Grandeur = new Car.CarName("그랜다이저", 2009);
    System.out.printf("모델 = %s, 년식 = %d\n", Grandeur.Model, Grandeur.Year);
  }
예제 #4
0
 public static void main(String[] args) {
   WeldContainer weldContainer = new Weld().initialize();
   Car car = weldContainer.instance().select(Car.class).get();
   weldContainer.instance().select(PoliceStation.class).get();
   weldContainer.instance().select(AARoadsideAssistant.class).get();
   car.getDriver().drive();
 }
  public static void main(String[] args) {
    CarFactory factory = new FordMotorsFactory();

    Car fiesta = factory.buildCar(CarType.FIESTA);

    System.out.println(fiesta.toString());
  }
  public static void main(String[] args) {
    Car bs = new Truck();

    bs.setSpeed(100);
    ((Truck) bs).setCargo(10);
    bs.showCurrentSpeed();
  }
예제 #7
0
 public static void initializeMap(int mapNumber) {
   int[][] table = Boards.getMap(mapNumber);
   // Create an ArrayList<ArrayList<Car>> filled with null
   for (int y = 0; y < 6; y++) {
     ArrayList<Car> temp = new ArrayList<Car>();
     for (int x = 0; x < 6; x++) {
       temp.add(null);
     }
     map.add(temp);
   }
   // Add the cars to the ArrayList
   for (int y = 0; y < table.length; y++) {
     Car car = new Car(y, table[y][3], table[y][0] == 0);
     if (car.iSHorisontal()) {
       for (int i = 0; i < car.getSize(); i++) {
         map.get(table[y][2]).set(table[y][1] + i, car);
       }
     } else {
       for (int i = 0; i < car.getSize(); i++) {
         map.get(table[y][2] + i).set(table[y][1], car);
       }
     }
   }
   System.out.println(map);
 }
  public ArrayList<Car> getBestCars(ArrayList<Attribute> attributes) {
    final StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
    ksession.setGlobal("list", new ArrayList<Object>());
    ArrayList<Car> cars = (ArrayList<Car>) CarLoader.loadFile();

    for (Car car : cars) ksession.insert(car);

    ksession.insert(new Attribute("Seguridad", 5));
    ksession.insert(new Attribute("Confort", 5));
    ksession.insert(new Attribute("Entretenimiento", 5));
    ksession.insert(new Attribute("Potencia", 5));
    ksession.insert(new Attribute("Design", 4));
    ksession.insert(new Attribute("Ruta", 0));
    ksession.insert(new Attribute("MenoresSN", 0));
    ksession.insert(new Attribute("DistanciaMes", 0));
    ksession.insert(new Attribute("CantViajes", 0));
    ksession.insert(new Attribute("Carga", 0));
    ksession.insert(new Attribute("CajaAutomatica", 0));
    ksession.insert(new Attribute("MP3", 0));
    ksession.insert(new Attribute("Tecnologia2", 0));

    for (Attribute attribute : attributes) ksession.insert(attribute);

    ksession.fireAllRules();
    ksession.dispose();

    ArrayList<Car> resultCar = new ArrayList<Car>();
    Collections.sort(cars);

    for (Car car : cars) {
      if (car.getAptitud() > 0) resultCar.add(car);
      if (resultCar.size() == 15) break;
    }
    return resultCar;
  }
예제 #9
0
  private void prepareTestData() {

    car1 = newCar("Black", "0B6 6835", "Škoda", 200.0);
    car2 = newCar("Red", "7B4 0044", "BMW", 500.0);
    car3 = newCar("White", "8B5 0983", "Volkwagen", 300.0);

    customer1 = newCustomer("Vitalii", "Chepeliuk", "Komarov", "5-20-86", "AK 373979");
    customer2 = newCustomer("Juraj", "Kolchak", "Komarov", "5-34-86", "AK 372548");
    customer3 = newCustomer("Martin", "Jirman", "Lazhot", "5-25-87", "AK 251245");

    carManager.addCar(car1);
    carManager.addCar(car2);
    carManager.addCar(car3);

    customerManager.addCustomer(customer1);
    customerManager.addCustomer(customer2);
    customerManager.addCustomer(customer3);

    carWithoutID = newCar("Green", "8B3 9763", "Audi", 400.0);
    carNotInDB = newCar("Blue", "3B6 8463", "Peugeot", 0.0);
    carNotInDB.setID(car3.getID() + 100);

    customerWithoutID = newCustomer("Martin", "Pulec", "Brno", "5-11-24", "AK 897589");
    customerNotInDB = newCustomer("Lukas", "Rucka", "Brno", "5-21-06", "AK 256354");
    customerNotInDB.setID(customer3.getID() + 100);
    customerNotInDB.setActive(true);
  }
예제 #10
0
  public ArrayList store() {
    Configuration cfg = new Configuration();
    cfg.configure();
    SessionFactory sf = cfg.buildSessionFactory();
    Session hs = sf.openSession();

    String hqlquery = "from com.mangium.Car";
    Query query = hs.createQuery(hqlquery);
    ArrayList list = (ArrayList) query.list();
    Iterator i = list.iterator();

    cr = new ArrayList();

    while (i.hasNext()) {
      Car c = (Car) i.next();
      System.out.println(c.getCarid());
      System.out.println(c.getCarname());
      System.out.println(c.getCarcost());
      System.out.println(c.getCartype());
      cr.add(c);
    }
    hs.close();
    sf.close();

    System.out.println(cr);
    setCr(cr);
    return cr;
  }
예제 #11
0
 @Override
 public Car getObject() throws Exception {
   System.out.println("FactoryBean getObject() run...");
   Car car = new Car();
   car.setName("myCar");
   return car;
 }
예제 #12
0
	synchronized void enterLaneB(Car car) throws InterruptedException {
		while (currentWeightA + currentWeightB + car.getWeight() >= maximumWeight || Math.abs(currentWeightA - currentWeightB + car.getWeight()) >= maximumDifference) {
			wait();
		}
		currentWeightB += car.getWeight();
		notifyAll();
	}
예제 #13
0
 @Override
 public int compare(Car o1, Car o2) {
   if (o1.getCarModelName().equalsIgnoreCase(o2.getCarModelName())) {
     return 0;
   } else {
     return o1.getCarModelName().compareTo(o2.getCarModelName());
   }
 }
예제 #14
0
 @Override
 public int compare(Car o1, Car o2) {
   if (o1.getCarMPG() == o2.getCarMPG()) {
     return 0;
   } else {
     return o1.getCarMPG() > o2.getCarMPG() ? 1 : -1;
   }
 }
예제 #15
0
 public void modifyCar(int id, int price, String name, int model, String color) {
   Car temp = (Car) cars.get(id);
   temp.setPrice(price);
   temp.setName(name);
   temp.setModel(model);
   temp.setColor(color);
   cars.set(id, temp);
 }
예제 #16
0
파일: Sample6.java 프로젝트: yonosuke/daily
  /** @param args */
  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Car car1 = new Car();
    car1.show();

    Car car2 = new Car(1234, 20.5);
    car2.show();
  }
예제 #17
0
 public static void main(String[] args) {
   int way;
   Car myCar = new Car();
   myCar.start();
   way = myCar.drive(5);
   System.out.println(way);
   myCar.stop();
 }
예제 #18
0
파일: CarSim.java 프로젝트: 13djwright/CS2
 // this adds a car based on a certain percentage
 public static void addCar(String s, Queue<Car> q, double p, int a) {
   if (r.nextDouble() < p) {
     int timeset = setTime(q, s, a);
     Car temp = new Car(s, a, timeset, timeset);
     q.offer(temp);
     log = log + temp.display() + "\n";
   }
 }
예제 #19
0
 private int getDist(Car car) {
   Coords x2 = car.getPos();
   Coords x1 = getPos();
   int distance = 0;
   distance = (x2.x - x1.x) + (x2.y - x1.y);
   if (distance < 0) distance = distance * -1;
   return distance - car.getLength();
 }
예제 #20
0
 public void testLoadClassNoRoot() {
   Constructor constructor = new Constructor(new TypeDescription(Car.class));
   Yaml yaml = new Yaml(constructor);
   Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
   assertEquals("12-XP-F4", car.getPlate());
   List<Wheel> wheels = car.getWheels();
   assertNotNull(wheels);
   assertEquals(5, wheels.size());
 }
예제 #21
0
 /**
  * equals method
  *
  * <p>Explanation: Functional method that compares o to this Vehicle returns true if the two have
  * the same VIN
  *
  * <p>List of Local Variables: - Let c be the instance of the Car class
  *
  * @param o: specified object being compared to this Car
  * @return (boolean) true if equal, false if not equal
  */
 public boolean equals(Object o) {
   if (o instanceof Car) {
     Car c = (Car) o;
     if (c.getVIN().equals(this.getVIN())) {
       return true;
     }
   }
   return false;
 }
예제 #22
0
  public static void main(String[] args) {
    Car car1;
    car1 = new Car();

    car1.num = 1234;
    car1.gas = 20.5;

    System.out.println("車號是" + car1.num + "。");
    System.out.println("汽油量是" + car1.gas + "。");
  }
예제 #23
0
  @Test
  public void testGetItemImage() {
    Car car = new Car(x, y, carTemplate);

    assertEquals(null, car.getItemImage());

    car.receiveItem(new Item(0, 0));

    assertNotNull(car.getItemImage());
  }
예제 #24
0
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    x = 100;
    y = 200;
    carTemplate = new CarTemplate(CarTemplate.CAR_BLUEWHITE);

    car = new Car(x, y, carTemplate);
    w = car.getWidth();
    h = car.getHeight();
  }
예제 #25
0
  public static void main(String[] args) {
    // Create an instance of Car with year as 2015
    Car c = new Car(2015);

    // Create a Tire for that car of 9.0 inch radius
    Car.Tire t = c.new Tire(9.0);

    System.out.println("Car's year:" + c.getYear());
    System.out.println("Car's tire radius:" + t.getRadius());
  }
예제 #26
0
  // 停止中はPにシフトできる
  @Test
  public void allowsShiftToParkWhenNotMoving() {
    transmission.shift(Gear.DRIVE);
    car.accelerateTo(30);
    car.brakeToStop();

    transmission.shift(Gear.PARK);

    assertThat(transmission.getGear(), equalTo(Gear.PARK));
  }
예제 #27
0
파일: Car.java 프로젝트: CY2012/Hello-World
 public static void main(String[] args) {
   Car c = new Car(4, "黑色", 1000, 5);
   c.speedUp();
   c.speedDown();
   c.speedDown();
   c.speedDown();
   c.speedDown();
   c.speedDown();
   c.speedDown();
 }
예제 #28
0
  public static void main(String args[]) {
    Car car_1 = new Car();
    Van van_1 = new Van();

    car_1.start();
    car_1.brake();
    van_1.start();
    car_1.pressHorn();
    van_1.brake();
  }
예제 #29
0
 public static void main(String[] args) {
   Car grandPrix = new Car();
   Car focus = new Car("Ford", "Focus", "black", 2000);
   System.out.println(grandPrix);
   System.out.println(focus);
   System.out.println(focus.equals(grandPrix));
   Car aCar = new Car();
   aCar.set();
   System.out.println(aCar);
 }
예제 #30
0
  public String getCarid() {

    car = new Car();
    car.setCarid(this.carid);
    car.setCarname(this.carname);
    car.setCarcost(this.carcost);

    this.car = car;
    return carid;
  }