Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author iris software
- */
- public class produtos {
- public static void cadastrarProduto() throws Exception {
- int op1;
- do {
- //menu
- System.out.println("PRODUTOS\n");
- System.out.println("1 - ADICIONAR NOVO");
- System.out.println("2 - CONSULTAR");
- System.out.println("3 - VOLTAR");
- //cadastro dos produtos
- op1 = (new Scanner(System.in)).nextInt();
- if(op1==1) {
- //salvando produtos
- String ctn ="";
- String[] registro = ctn.split("\n");
- String[] nomeProduto = new String[registro.length];
- String[][] infoProduto = new String[registro.length][2];
- double[][] numerosProduto = new double[registro.length][3];
- double cod, qtd, preco;
- int count = 0;
- String nome, descricao, fornecedor = null;
- System.out.println("CODIGO:");
- cod = (new Scanner(System.in)).nextDouble();
- for (int x = 0; x < nomeProduto.length; x++) {
- if (cod == (numerosProduto[x][0])) {
- System.out.println("Código já cadastrado! digite um novo código");
- cod = (new Scanner(System.in)).nextDouble();
- }
- }
- System.out.println("NOME:");
- nome = (new Scanner(System.in)).nextLine();
- for (int x = 0; x < nomeProduto.length; x++) {
- if (nome.equals(nomeProduto[x])) {
- System.out.println("Já existe um produto com essse nome");
- nome = (new Scanner(System.in)).nextLine();
- }
- }
- System.out.println("DESCRICAO:");
- descricao = (new Scanner(System.in)).nextLine();
- for(int x = 0; x<nomeProduto.length; x++) {
- descricao.equals(infoProduto[x][0]);
- }
- System.out.println("PRECO UNITARIO:");
- preco = (new Scanner(System.in)).nextDouble();
- for (int x = 0; x < nomeProduto.length; x++) {
- preco = (numerosProduto[x][1]);
- }
- System.out.println("QUANTIDADE EM ESTOQUE:");
- qtd = (new Scanner(System.in)).nextDouble();
- for (int x = 0; x < nomeProduto.length; x++) {
- qtd = (numerosProduto[x][2]);
- }
- System.out.println("FORNECEDOR:");
- fornecedor = (new Scanner(System.in)).nextLine();
- for(int x = 0; x<nomeProduto.length; x++) {
- fornecedor.equals(infoProduto[x][1]);
- }
- nomeProduto[count] = nome;
- infoProduto[count][0] = descricao;
- infoProduto[count][1] = fornecedor;
- numerosProduto[count][0] = cod;
- numerosProduto[count][1] = preco;
- numerosProduto[count][2] = qtd;
- count++;
- for(int x=0; x<nomeProduto.length; x++){
- ctn = ctn+numerosProduto[x][0]+"|"+nomeProduto[x]+"|"+infoProduto[x][0]+"|"+numerosProduto[x][1]+"|"+numerosProduto[x][2]+"|"+infoProduto[x][1]+"\n";
- arquivo.gravar("produtos.txt", ctn);
- }
- }
- }while(op1 !=3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement