//Titel:            Testbeispiel für Interface-Technik
//Version:          1.0
//Copyright:        HS-Harz, FB AI
//Autor:            Dipl.-Inf. Dipl.-Ing. (FH) Michael Wilhelm
//Firma:
//Beschreibung:


// Interface Beispiel

import java.awt.*;
import java.awt.event.*;

import java.io.*;

import java.util.Vector;






public class Test_Interface {



   private static void pause() {
    try {
      System.in.read();
    }
    catch (IOException e) {
    }
  }  // pause


  private void test1() {
    rechteck r1, r2;
    kreis k1, k2;
    IPrint ip;
    r1 = new rechteck(1);
    r2 = new rechteck(2);

    k1 = new kreis(3);
    k2 = new kreis(4);

    System.out.println( r1.print() );
    System.out.println( r2.print() );

    System.out.println( k1.print() );
    System.out.println( k2.print() );

    ip = r1;
    System.out.println( ip.print() );
    ip = k1;
    System.out.println( ip.print() );
    System.out.println( );
    System.out.println( );
  }

  private void test2() {
    rechteck r[];
    kreis k[];
    quader q[];
    kugel kg[];
    IPrint ip[];
    int i;
    r = new rechteck[3];
    for (i=0; i<3; i++) r[i] = new rechteck(i+1);

    k = new kreis[3];
    for (i=0; i<3; i++) k[i] = new kreis(10+i);

    q = new quader[3];
    for (i=0; i<3; i++) q[i] = new quader(1500+i);
    kg = new kugel[3];
    for (i=0; i<3; i++) kg[i] = new kugel(1000+i);


    ip = new IPrint[12];

    ip[0]  = r[0];
    ip[1]  =  k[2];
    ip[2]  =  k[1];
    ip[3]  = r[1];
    ip[4]  =  k[0];
    ip[5]  = r[2];

    ip[6]  = q[0];
    ip[7]  = q[1];
    ip[8]  = q[2];
    ip[9]  = kg[2];
    ip[10] = kg[1];
    ip[11] = kg[0];
    for (i=0; i<12; i++)
      System.out.println( ip[i].print() );
  }

    // MAIN
  static public void main(String[] args) {
    Test_Interface v = new Test_Interface();
    v.test1();
    v.test2();
    pause();
  }

}


interface IPrint {
	public String print();
}


abstract class flaeche implements IPrint {

  int nr;

  public flaeche(int nr) {
    this.nr = nr;
  }
} // flaeche


class rechteck extends flaeche {

  public rechteck(int nr) {
    super(nr);
  }

	public String print() {
    return nr+" Ich bin ein Rechteck";
  }

}

class kreis extends flaeche {

  public kreis(int nr) {
    super(nr);
  }
	public String print() {
    return nr+" Ich bin ein Kreis";
  }

}


abstract class koerper implements IPrint {

  int nr;

  public koerper(int nr) {
    this.nr = nr;
  }
} // koerper


class quader extends koerper {

  public quader(int nr) {
    super(nr);
  }

	public String print() {
    return nr+" Ich bin ein Quader";
  }

}

class kugel extends koerper {

  public kugel(int nr) {
    super(nr);
  }
	public String print() {
    return nr+" Ich bin eine Kugel";
  }

}



