Advertisement
alandmx40

Projeto Lista de Compra - Anteriror

Sep 5th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.78 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.  
  7. /**
  8.  *
  9.  * @author alann
  10.  */
  11. import java.util.ArrayList;
  12. import java.util.Scanner;
  13.  
  14. public class Principal {
  15.    
  16.     public static void main(String args[]){
  17.        
  18.         ArrayList<Compra> newcompra = new ArrayList<>();
  19.         Scanner ent = new Scanner(System.in);
  20.        
  21.         String n, u, l, t, aux3, aux4, aux5, aux6, aux7, aux8, mes;
  22.         float q, p, mult, total = 0, aux = 0, aux2 = 100, aux10;
  23.         int a = 0, b, aux9, aux11 = 0;
  24.        
  25.         while(a != 7){
  26.            
  27.             System.out.println("O que deseja fazer?\n1 - Lista de Compra (Anterior)\n2 - Consultar produtos por local\n3 - Cadastro de Produto (Previsão)\n4 - Lista de Previsão\n5 - Alterar Produto\n6- Produto mais e menos comprado\n7 - Sair\n");
  28.             a = ent.nextInt();
  29.            
  30.             switch (a){
  31.                 case 1:
  32.                    
  33.                     Compra c1 = new Compra(null, null, null, null, 0, 0);
  34.                    
  35.                     c1.setNomep("Arroz");
  36.                     c1.unidade = "Kg";
  37.                     c1.local = "Atacadão";
  38.                     c1.quantidade = 7;
  39.                     c1.preco = (float) 2.2;
  40.                    
  41.                     newcompra.add(c1);
  42.                    
  43.                     Compra c2 = new Compra(null, null, null, null, 0, 0);
  44.                    
  45.                     c2.setNomep("Feijão");
  46.                     c2.unidade = "Kg";
  47.                     c2.local = "Atacadão";
  48.                     c2.quantidade = 5;
  49.                     c2.preco = (float) 2.99;
  50.                    
  51.                     newcompra.add(c2);
  52.                    
  53.                     Compra c3 = new Compra(null, null, null, null, 0, 0);
  54.                    
  55.                     c3.setNomep("Leite");
  56.                     c3.unidade = "l";
  57.                     c3.local = "São Luiz";
  58.                     c3.quantidade = 8;
  59.                     c3.preco = 2;
  60.                    
  61.                     newcompra.add(c3);
  62.                    
  63.                     Compra c4 = new Compra(null, null, null, null, 0, 0);
  64.                    
  65.                     c4.setNomep("Carne");
  66.                     c4.unidade = "Kg";
  67.                     c4.local = "Bella Compra";
  68.                     c4.quantidade = 10;
  69.                     c4.preco = (float) 7.5;
  70.                    
  71.                     newcompra.add(c4);
  72.                    
  73.                     System.out.println("Lista de compras");
  74.                     System.out.println("Julho\n");
  75.                    
  76.                     for(b = 0; b < newcompra.size();b++){
  77.                        
  78.                         newcompra.get(b).listaProdutos();
  79.                         System.out.println("");
  80.                        
  81.                     }
  82.                    
  83.                     System.out.println("\nTotal gasto: R$ "+(c1.y+c2.y+c3.y+c4.y)+"\n");
  84.                    
  85.                     break;
  86.                 case 2:
  87.                    
  88.                     System.out.println("Qual local deseja consultar?");
  89.                     aux3 = ent.nextLine();
  90.                     aux3 = ent.nextLine();
  91.                    
  92.                     aux4 = aux3.toUpperCase();
  93.                    
  94.                     for(b = 0; b < newcompra.size();b++){
  95.                        
  96.                         aux5 = newcompra.get(b).local.toUpperCase();
  97.                        
  98.                         if(aux4.equals(aux5)){
  99.                            
  100.                             newcompra.get(b).listaProdutosPrevisao();
  101.                            
  102.                         }
  103.                        
  104.                     }
  105.                    
  106.                     break;
  107.                 case 3:
  108.                    
  109.                     System.out.println("");
  110.                     System.out.println("Nome do Produto:");
  111.                     n = ent.nextLine();
  112.                     n = ent.nextLine();
  113.                     System.out.println("Unidade de Medida:");
  114.                     u = ent.next();
  115.                     System.out.println("Local:");
  116.                     l = ent.nextLine();
  117.                     l = ent.nextLine();
  118.                     System.out.println("Tipo");
  119.                     t = ent.next();
  120.                     System.out.println("Quantidade:");
  121.                     q = ent.nextFloat();
  122.                     System.out.println("Preco:");
  123.                     p = ent.nextFloat();
  124.                     System.out.println("");
  125.                    
  126.                     newcompra.add(new Compra(n, u, l, t, q, p));
  127.                    
  128.                     break;
  129.                    
  130.                 case 4:
  131.                     System.out.println("");
  132.                     System.out.println("Lista de Previsão");
  133.                     System.out.println("Agosto\n");
  134.                    
  135.                     for(b = 0; b < newcompra.size();b++){
  136.                        
  137.                         newcompra.get(b).listaProdutosPrevisao();
  138.                         System.out.println("");
  139.                     }
  140.                    
  141.                     for(b = 0; b < newcompra.size();b++){
  142.                        
  143.                         total = total + newcompra.get(b).y;
  144.                        
  145.                     }
  146.                    
  147.                     System.out.println("\nTotal previsto: R$ "+total);
  148.                     System.out.println("");
  149.                    
  150.                     break;
  151.                 case 5:
  152.                    
  153.                     System.out.println("Qual produto deseja alterar?");
  154.                     aux6 = ent.nextLine();
  155.                     aux6 = ent.nextLine();
  156.                    
  157.                     aux7 = aux6.toUpperCase();
  158.                    
  159.                     for(b = 0; b < newcompra.size();b++){
  160.                        
  161.                         aux8 = newcompra.get(b).getNomep().toUpperCase();
  162.                        
  163.                         if(aux7.equals(aux8)){
  164.                            
  165.                             System.out.println("O que deseja alterar?\n1 - Local\n2 - Tipo\n3 - Quantidade\n4 - Preco");
  166.                             aux9 = ent.nextInt();
  167.                            
  168.                             switch (aux9){
  169.                                 case 1:
  170.                                     System.out.println("Novo Local:");
  171.                                     newcompra.get(b).local = ent.nextLine();
  172.                                     newcompra.get(b).local = ent.nextLine();
  173.                                     break;
  174.                                 case 2:
  175.                                     System.out.println("Novo Tipo:");
  176.                                     newcompra.get(b).tipo = ent.next();
  177.                                     break;
  178.                                 case 3:
  179.                                    
  180.                                     total = total - newcompra.get(b).y;
  181.                                    
  182.                                     System.out.println("Nova quantidade:");
  183.                                     newcompra.get(b).quantidade = ent.nextFloat();
  184.                                     break;
  185.                                 case 4:
  186.                                    
  187.                                     total = total - newcompra.get(b).y;
  188.                                    
  189.                                     System.out.println("Novo Preco:");
  190.                                     aux10 = ent.nextFloat();
  191.                                     newcompra.get(b).setPreco(aux10);
  192.                                    
  193.                                     break;
  194.                                 default:
  195.                                     break;
  196.                             }
  197.                            
  198.                         }
  199.                        
  200.                     }
  201.                     break;
  202.                 case 6:
  203.                     for(b = 0; b < newcompra.size();b++){
  204.                        
  205.                         if(newcompra.get(b).quantidade >= aux){
  206.                            
  207.                             aux = newcompra.get(b).quantidade;
  208.                            
  209.                         }else {
  210.                         }
  211.                        
  212.                         if(newcompra.get(b).quantidade <= aux2){
  213.                            
  214.                             aux2 = newcompra.get(b).quantidade;
  215.                            
  216.                         }else{
  217.                         }
  218.                        
  219.                     }
  220.                    
  221.                     System.out.println("Produto(s) mais comprado(s)");
  222.                    
  223.                     for(b = 0; b < newcompra.size();b++){
  224.                        
  225.                         if(aux == newcompra.get(b).quantidade){
  226.                            
  227.                             newcompra.get(b).listaProdutosPrevisao();
  228.                            
  229.                         }
  230.                        
  231.                     }
  232.                    
  233.                     System.out.println("\nProduto(s) menos comprado(s)");
  234.                    
  235.                     for(b = 0; b < newcompra.size();b++){
  236.                        
  237.                         if(aux2 == newcompra.get(b).quantidade){
  238.                            
  239.                             newcompra.get(b).listaProdutosPrevisao();
  240.                            
  241.                         }
  242.                        
  243.                     }
  244.                     break;
  245.                 default:
  246.                     break;
  247.             }
  248.            
  249.         }
  250.        
  251.     }
  252.    
  253. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement