Exemple #1
0
 private static Articulo scanArticulo() {
   Articulo articulo = new Articulo();
   articulo.nombre = scanString("   Nombre: ");
   articulo.categoria = scanLong("Categoria: ");
   articulo.precio = scanBigDecimal("   Precio: ");
   return articulo;
 }
  public boolean comprobarArticuloExistente(Articulo art) {

    boolean existe = false;
    if (FICHERO.exists()) {
      try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(FICHERO))) {

        while (true) {
          Articulo articuloActual = (Articulo) ois.readObject();
          if (articuloActual.getId() == art.getId()
              && articuloActual.getNombre().equals(art.getNombre())
              && articuloActual.getPrecio() == art.getPrecio()
              && articuloActual.getCantAlmacen() == art.getCantAlmacen()) {
            existe = true;
          }
        }

      } catch (ClassNotFoundException e) {

      } catch (EOFException e) {

      } catch (IOException e) {

      }
    }
    return existe;
  }
Exemple #3
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.out.println("Bienvenido a tejaStore...\n Ejemplo de alta y modificacion de art");
    EntityManagerFactory emf = DBHandler.OpenConnectionProd();
    EntityManager em = emf.createEntityManager();
    Marca marca = new Marca("Coca-Cola");
    marca.alta_ABM(em);

    for (int i = 0; i < 100; i++) {

      Articulo art =
          new Articulo(00000001, "Coca-Cola", 100, 20, (float) 14.2, (float) 24.2, 0, marca);
      art.alta_ABM(em);
      if (i % 2 == 0) {
        art.setPrecio_venta((float) 40.00);
        art.modificacion_ABM(em);
      }
      System.out.println(art.getMarca().getNombre());
    }

    em.close();
    DBHandler.closeConnectionProd(emf);
  }
 @Test
 public void test() {
   assertEquals(5, nuevo.resultado());
 }
Exemple #5
0
 public static void main(String args[]) {
   Articulo a1 = new Alimento(990034, "Chocolate a la taza", 2.5, true);
   System.out.println("Precio total: " + a1.precioTotal(7)); // 13.75 = (7 * 2.5 - 2 * 2.5) * 1.10
   Alimento a2 = new Alimento(990268, "Yogur liquido", 1.25, false);
   System.out.println("Precio total: " + a2.precioTotal(4)); // 5.5 = (4 * 1.25 - 0.0) * 1.10
 }