// Komplex.java MM 2010 /** * Komplexe Zahlen */ public class Komplex { /* ------------------------------------------------- */ // (a) Attribute /** * Realteil re einer komplexen Zahl. */ /** * Imaginaerteil im einer komplexen Zahl. */ /* ------------------------------------------------- */ // (a) set-Methode /** * Setzt Real- und Imaginaerteil einer komplexen Zahl. * @param real Realteil der komplexen Zahl * @param imaginaer Imaginaerteil der komplexen Zahl */ public void setKomplex( double real, double imaginaer) { } /* ------------------------------------------------- */ // get-Methode /** * Liest Realteil. * @return Realteil der komplexen Zahl */ public double getRe() { return re; } /** * Liest Imaginaerteil. * @return Imaginaerteil der komplexen Zahl */ public double getIm() { return im; } /* ------------------------------------------------- */ // (b) toString /** * Darstellen einer komplexen Zahl. * @return komplexen Zahl in linearer Schreibweise */ public String toString() { } /* ------------------------------------------------- */ // (c) Operationen /** * Addition. * @param a komplexe Zahl * @return komplexe Zahl */ public Komplex add( Komplex a) { double x, y; x = re + a.getRe(); y = im + a.getIm(); Komplex b = new Komplex(); b.setKomplex( x, y); return b; } /** * Subtraktion. * @param a komplexe Zahl * @return komplexe Zahl */ public Komplex sub( Komplex a) { double x, y; x = re - a.getRe(); y = im - a.getIm(); Komplex b = new Komplex(); b.setKomplex( x, y); return b; } /** * Multiplikation. * @param a komplexe Zahl * @return komplexe Zahl */ public Komplex mult( Komplex a) { } /** * Division. * @param a komplexe Zahl * @return komplexe Zahl */ public Komplex div( Komplex a) { } /* ------------------------------------------------- */ /** * Testprogramm zu komplexe Zahlen */ public static void main( String[] args) { // (d) Komplexe Zahlen a, b, c, d // (e) Testbeispiel 1 // (e) Testbeispiel 2 // Ausgabe System.out.println( "c = " + c); // (e) System.out.println( "d = " + d); // (e) } }