Skip to main content

boleta, cliente, nombre en Java

import java.util.ArrayList;
public class Cliente {
private String nombre;
private ArrayList boletas;
public Cliente(String nombre) {
this.nombre = nombre;
this.boletas = new ArrayList();
}
public String getNombre() {
return this.nombre;
}
public void agregarBoleta(Boleta boleta) {
boletas.add(boleta);
}
public void imprimirHistorial() {
Boleta b;
System.out.println("Nombre: " + nombre);
for (int i=0; i
b = (Boleta)boletas.get(i);
b.imprimir();
}
}
}
public class Articulo {
private String descripcion;
private int stock;
private int precio;
public Articulo(String descripcion,int stock,int precio){
this.descripcion = descripcion;
this.stock = stock;
this.precio = precio;
}
public String getDescripcion() {
return this.descripcion;
}
public int getStock() {
return this.stock;
}
public int getPrecio() {
return this.precio;
}
}
import java.util.ArrayList;
public class Boleta {
private String fecha;
private int total;
private ArrayList articulos;
public Boleta(String fecha) {
this.fecha = fecha;
this.total = 0;
this.articulos = new ArrayList();
}
public void agregarArticulo(Articulo articulo) {
articulos.add(articulo);
total += articulo.getPrecio();
}
public void imprimir() {
Articulo a;
System.out.println("Fecha: " + fecha);
for (int i=0; i
a = (Articulo)articulos.get(i);
System.out.println(a.getDescripcion() + " " + a.getPrecio());
}
System.out.println("Total: " + total);
}
}
public class Main {
public static void main(String[] args) {
Cliente c1 = new Cliente("Pepe");
Articulo a1 = new Articulo("Lavadora", 10, 100000);
Articulo a2 = new Articulo("Televisor", 5, 70000);
Articulo a3 = new Articulo("Cafetera", 25, 15000);
Boleta b1 = new Boleta("18/abril/2007");
Boleta b2 = new Boleta("19/abril/2007");
b1.agregarArticulo(a1);
b1.agregarArticulo(a3);
c1.agregarBoleta(b1);
b2.agregarArticulo(a1);
b2.agregarArticulo(a1);
b2.agregarArticulo(a2);
c1.agregarBoleta(b2);
c1.imprimirHistorial();
}
}

Comments

carlos said…
no entiendo los codigos. de que son?
chocobo said…
es codigo para netbeans, uno de mis trabajos de la universidad. lo postie aqui para tenerlo de referencia.
Camila said…
Yo también muchas veces anoto distintos códigos que necesito recordar o cosas asi. Suelo anotar los pasos para descargar e instalar antivirus y de esta manera tener una buena cobertura y seguridad en mi computadora
chocobo said…
Camila, dispones de un blogspot de codigo, relacionado con sistemas o de ocio puro ??

Popular posts from this blog

Llamar a 1 800 en USA desde Mexico

Cómo llamar números gratis en USA [toll free] desde México Ok, resulta que alguna vez los números gratis, se llamaban números 1- 800 (01-800 desde México). Pero lo malo de los números es que se acaban, Sobre todo en USA que les encanta vender todo. Ahora los Números gratis pueden ser 1 - 800, 1 - 877, 1 - 866 Para los americanos es cuestion de acostumbrarse, pero para nosotros los usuarios de telmex ¿cómo le hacemos si queremos marcar? Pues en primera pagando, los números gratis en USA usualmente no son gratis desde otros paises. Y en segunda, marcando correctamente. Muchos ya se saben el de los 800, es nada mas cuestion de cambiar el 01 - 800 por 001 - 881, pero y los 1 - 866 ? y los 1 - 877 ? Ahhh pues en mi otro blog ya tenía una entrada con una tablita que lo explica: Si el numero comienza con 1 888 se marca: 001 881 Si el numero comienza con 1 877 se marca: 001 882 Si el numero comienza con 1 866 se marca: 001 883 ¿Por qué? No tengo la más mínima idea, supongo que...

ESET instaladores x86 - x64 ESP,ENG,PTB (Shareware)

- Español Latino ESET NOD32 Antivirus http://download.eset.com/ download/win/eav/eav_nt32_esl. msi http://download.eset.com/ download/win/eav/eav_nt64_esl. msi ESET Smart Security http://download.eset.com/ download/win/ess/ess_nt32_esl. msi http://download.eset.com/ download/win/ess/ess_nt64_esl. msi - Español España ESET NOD32 Antivirus http://download.eset.com/ download/win/eav/eav_nt32_esn. msi http://download.eset.com/ download/win/eav/eav_nt64_esn. msi ESET Smart Security http://download.eset.com/ download/win/ess/ess_nt32_esn. msi http://download.eset.com/ download/win/ess/ess_nt64_esn. msi - Ingles ESET NOD32 Antivirus http://download.eset.com/ download/win/eav/eav_nt32_enu. msi http://download.eset.com/ download/win/eav/eav_nt64_enu. msi ESET Smart Security http://download.eset.com/ download/win/ess/ess_nt32_enu. msi http://download.eset.com/ download/win/ess/ess_nt64_enu. msi - Portugues ESET NOD32 Antivirus http://download.eset.com/ download/win/eav/eav_nt32_ptb. msi http://...

10 commands you should master when working with the Cisco IOS

The Cisco IOS provides thousands of commands, and configuring it can be challenging. Here are 10 commands you need to know, inside and out, when using the Cisco IOS. #1: The “?” It may seem entirely too obvious that you should know how to type  ?  to ask for help when using the Cisco IOS. However, the Cisco IOS is completely different from other operating systems when it comes to using the question mark (help key). As the IOS is a command-line operating system with thousands of possible commands and parameters, using the ? can save your day. You can use the command in many ways. First, use it when you don’t know what command to type. For example, type  ?  at the command line for a list of all possible commands. You can also use ? when you don’t know what a command’s next parameter should be. For example, you might type show ip ?  If the router requires no other parameters for the command, the router will offer CR as the only option. Finally, use ? to se...