// DEMO DE HERENCIA E INTERFAZ (TABLA DE MULTIPLICAR)
/// EJEMPLO DE HERENCIA ESCALONADA
//=====================================
/*
public class Programa_3 extends Multiplicar
{
Integer Tabla = new Integer(7); // TABLA DEL SIETE
Integer Limite = new Integer("8"); // LIMITE DE LA TABLA
public static void main(String CAD[]) { new Programa_3(); }
public Programa_3()
{
int F1 = 0, F2 = 0;
for (F2 = 0; F2 <= Limite.intValue(); F2++)
{
Operacion(Tabla.intValue(), F2);
Muestra(Tabla.intValue(), F2, RESP);
}
}
}
class Imprime
{
public Imprime() { }
void Muestra(int V1, int V2, int RESP) { System.out.println("" + V1 + "*" + V2 + " = " + RESP); }
}
class Multiplicar extends Imprime
{
int RESP = 0;
public Multiplicar() {}
void Operacion(int V1, int V2) { RESP = V1*V2; }
}
*/
/// EJEMPLO DE INTERFAZ
//=====================================
public class Programa_3 implements INTERFAZ
{
Integer Tabla = new Integer(7); // TABLA DEL SIETE
Integer Limite = new Integer("8"); // LIMITE DE LA TABLA
int RESP = 0;
public static void main(String CAD[]) { new Programa_3(); }
public Programa_3()
{
int F1 = 0, F2 = 0;
for (F2 = 0; F2 <= Limite.intValue(); F2++)
{
Multiplicar(Tabla.intValue(), F2);
Imprime(Tabla.intValue(), F2, RESP);
}
}
// IMPLEMENTACION DE LOS METODOS DE LA INTERFAZ
public void Imprime(int V1, int V2, int RESP)
{ System.out.println("" + V1 + "*" + V2 + " = " + RESP); }
public void Multiplicar(int V1, int V2)
{ RESP = V1*V2; }
}
// OJO ... LA INTERFAZ SE DEBE GUARDAR EN UN ARCHIVO LLAMADO
// INTERFAZ.java
public interface INTERFAZ
{
void Imprime(int a, int b, int c);
void Multiplicar(int a, int b);
}