Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/09/2013, 20:27
aglayo2009
 
Fecha de Ingreso: octubre-2009
Mensajes: 23
Antigüedad: 14 años, 6 meses
Puntos: 0
Exclamación metodo registrar producto con interfaz en java

buenas noches:

en un ejercicio de poo, esto trabajando en con interfaces, este es el ejemplo de codigo que tengo:

clase interfaz:
public interface Interfaz {

public void registrar();
public void imprimir();


}

clase producto:
public class Producto implements Interfaz
{
public int Codigo;
public String Nombre;
public float Precio;
public int Cantidad_Stock;

public Producto()
{
this.Codigo=0;
this.Nombre="";
this.Precio=0;
this.Cantidad_Stock=0;
}

public Producto(int Codigo, String Nombre, float Precio, int Cantidad_Stock )
{
this.Codigo=Codigo;
this.Nombre=Nombre;
this.Precio=Precio;
this.Cantidad_Stock=Cantidad_Stock;

}

public void setCodigo(int Codigo)
{
this.Codigo=Codigo;

}
public int getCodigo()
{
return this.Codigo;
}
public void setNombre(String Nombre)
{
this.Nombre=Nombre;
}
public String getNombre()
{
return this.Nombre;
}
public void setPrecio(float Precio)
{
this.Precio=Precio;
}
public float getPrecio()
{
return this.Precio;
}
public void setCantidad_Stock(int Cantidad_Stock)
{
this.Cantidad_Stock=Cantidad_Stock;
}
public int getCantidad_Stock()
{
return this.Cantidad_Stock;
}
public void registrar()
{

System.out.print("Ingrese el Codigo del producto: ");
this.setCodigo(br.readLine());
System.out.print("Ingrese el Nombre del producto: ");
this.setNombre(br.readLine());
System.out.print("Ingrese el Precio del producto: ");
this.setPrecio(br.readLine());
System.out.print("Ingrese La Cantidad De Stock del producto: ");
this.setCantidad_Stock(br.readLine());
}
public void imprimir()
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Ingrese el Codigo del producto: " + this.getCodigo());
System.out.print("Ingrese el Nombre del producto: " + this.getNombre());
System.out.print("Ingrese el Precio del producto: " + this.getPrecio());
System.out.print("Ingrese La Cantidad De Stock del producto: " + this.getCantidad_Stock());
}
}
clase menu principal:
import java.io.*;

public class MenuPrincipal
{
static Producto miProducto = new Producto();
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

public static void main(String[] args) throws IOException
{
System.out.println("INGRESE LA OPCIÓN 1: Registrar 2: Imprimir");
int op= Integer.parseInt(br.readLine());
switch(op)
{
case 1:
System.out.print("Registre ");
miProducto.registrar();
break;
case 2:
System.out.print("imrpima");
miProducto.imprimir();
}
}
}
la pregunta es
en el metodo registrar como hago para que funcione ya que me sale error diciendo:
error:cannot find symbol