Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package es.uv.eu.practica1;
  7.  
  8. import java.util.HashSet;
  9. import javax.swing.JOptionPane;
  10.  
  11. /**
  12.  *
  13.  * @author marin
  14.  */
  15. public class Practica1 {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.        
  22.         HashSet<Cliente> clientes = new HashSet<Cliente>();
  23.         HashSet<Producto> productos = new HashSet<Producto>();
  24.         String nomc,nomp, dir, cantidad, precio ;
  25.         int continuar, cont, vip, cant, pr;
  26.         boolean V = false;
  27.        
  28.         do
  29.         {
  30.  
  31.             nomc=JOptionPane.showInputDialog(null,"Introduce tu nombre ");
  32.             dir=JOptionPane.showInputDialog(null,"Introduce tu direccion ");
  33.             vip= JOptionPane.showConfirmDialog(null,"¿Eres VIP?", "Seleccione la opcion deseada",JOptionPane.YES_NO_OPTION);
  34.            
  35.             if (vip == 0)
  36.                 V = true;
  37.             else if (vip == 1)
  38.                 V = false;
  39.                
  40.            
  41.            
  42.            
  43.             do
  44.             {
  45.                nomp=JOptionPane.showInputDialog(null,"Introduce el nombre del producto ");
  46.                cantidad =JOptionPane.showInputDialog(null,"Introduce la cantidad del producto: ");
  47.                precio =JOptionPane.showInputDialog(null,"Introduce el precio del producto: ");
  48.                cont= JOptionPane.showConfirmDialog(null,"¿Quieres añadir más productos?", "Seleccione la opcion deseada",JOptionPane.YES_NO_OPTION);
  49.                cant= Integer.parseInt(cantidad);
  50.                pr= Integer.parseInt(precio);
  51.                
  52.                Producto p = new Producto (nomp, cant, pr);
  53.                
  54.                productos.add(p);
  55.                
  56.             }while (cont == 0);
  57.            
  58.             continuar= JOptionPane.showConfirmDialog(null,"Quieres continuar?", "Seleccione la opcion deseada",JOptionPane.YES_NO_OPTION);
  59.             Cliente cliente = new Cliente(nomc,dir,V, productos);
  60.             clientes.add(cliente);
  61.            
  62.         } while (continuar == 0);  
  63.  
  64.         JOptionPane.showMessageDialog(null,clientes.toString());
  65.    
  66. }
  67.    
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement