doubts show products

0

I need to develop a program that allows me to enter products and show them hopefully filtering them according to some preference. I have three objects; enter products, show products and products. The idea is that the product class triggers the program, and the others have the code to enter and show products, but I have problems with relationships (passing attributes between classes) between objects. Can somebody help me?

CLASS ENTER PRODUCTS:

import java.util.Scanner;
public class IngresarProductos {
    private Scanner teclado;
    private String[] categoria;
    private String[] categoriaMarca;
    public void cargar() {
        teclado = new Scanner(System.in);
        categoria = new String[4];
        categoriaMarca = new String[4];
        System.out.println("Carga de productos");
        for(int f=0; f<categoria.length;f++) {
            System.out.print("Ingrese la categoría del producto ");
            categoria[f] = teclado.next();
            System.out.print("Ingrese la marca del producto ");
            categoriaMarca[f] = teclado.next();  
        }
    }
}

CLASS SHOW PRODUCTS:

    public class MostrarProductos {
        public void imprimir() {
            IngresarProductos nuevo = new IngresarProductos;
            for (int f = 0; f<categoria.length;f++) {
                System.out.println(categoria[f] + " - " + categoriaMarca[f]);               
            }
        }
    }

PRODUCT CLASS:

public class Productos {
    public static void main(String[] arg) {
        IngresarProductos nuevo = new IngresarProductos();
        nuevo.cargar();
        System.out.println("Lista de productos ingresados: ");
        nuevo.imprimir();
    }
}
    
asked by virtual8870 11.11.2017 в 21:54
source

0 answers