Einzelnen Beitrag anzeigen

Benutzerbild von Störtebeker
Störtebeker

Registriert seit: 9. Jul 2007
398 Beiträge
 
#1

JAVA: Mehrere Methoden in einer...

  Alt 13. Feb 2008, 19:49
Hallo,

wie kann ich mehrere Methoden in eine packen?

Momentan sieht die Klasse wie folgt aus:

Code:
 public class bruch
 {
   //BEGIN OF - Declaration of Variables

     int zaehler; // Numerator
     int nenner; // Denominator
     int zaehler2; // Numerator
     int nenner2; // Denominator
     int sum;
     int dif;
     int quo;
     int pro;

   //END OF - Declaration of Variables

  //BEGIN OF - Method "complete"
  public static void complete()
  {
    //BEGIN OF - Method "enterBruch"
    public String enterBruch()
    {
      System.out.println("BITTE GEBEN SIE DEN ZÄHLER AN:\t");
      zaehler = Tastatur.liesInt();
      System.out.println("\nBITTE GEBEN SIE DEN NENNER AN:\t");
      nenner = Tastatur.liesInt();
      return "---------------------------------------------------------";
    }
    //END OF - Method "enterBruch"
   
    //BEGIN OF - Method "enterBruch2"
    public String enterBruch2()
    {
      System.out.println("BITTE GEBEN SIE DEN 2. ZÄHLER AN:\t");
      zaehler2 = Tastatur.liesInt();
      System.out.println("\nBITTE GEBEN SIE DEN 2. NENNER AN:\t");
      nenner2 = Tastatur.liesInt();
      return "---------------------------------------------------------";
    }
    //END OF - Method "enterBruch2"

    //BEGIN OF - Method "valid"
    public String valid()
    {
      if (nenner > 0)
      return "<OK>";
      else
      return "<UNGÜLTIG>";
    }
    //END OF - Method "valid"
   
    //BEGIN OF - Method "valid2"
    public String valid2()
    {
      if (nenner2 > 0)
      return "<OK>";
      else
      return "<UNGÜLTIG>";
    }
    //END OF - Method "valid2"
   
    //BEGIN OF - Method "toString"
    public String toString()
    {
      return ""+zaehler+"/"+nenner;
    }
    //END OF - Method "toString"
   
    //BEGIN OF - Method "toString2"
    public String toString2()
    {
      return ""+zaehler2+"/"+nenner2;
    }
    //END OF - Method "toString2"

    //BEGIN OF - Method "getDouble"
    public double getDouble()
    {
      return (double)zaehler/nenner;
    }
    //END OF - Method "getDouble"
   
    //BEGIN OF - Method "getDouble2"
    public double getDouble2()
    {
      return (double)zaehler2/nenner2;
    }
    //END OF - Method "getDouble2"
   
    //BEGIN OF - Method "GreatestCommonDivisor(ggT)"
    public int GreatestCommonDivisor()
    {
      while (zaehler != nenner)
      {
       if (zaehler > nenner)
       zaehler = zaehler - nenner;
       else
       nenner = nenner - zaehler;
      }
      return zaehler;
    }
    //END OF - Method "GreatestCommonDivisor(ggT)"
   
    //BEGIN OF - Method "GreatestCommonDivisor2(ggT)"
    public int GreatestCommonDivisor2()
    {
      while (zaehler2 != nenner2)
      {
       if (zaehler2 > nenner2)
       zaehler2 = zaehler2 - nenner2;
       else
       nenner2 = nenner2 - zaehler2;
      }
      return zaehler2;
    }
    //END OF - Method "GreatestCommonDivisor2(ggT)"
   
    //BEGIN OF - Method "Addition"
    public int addition()
    {
      sum = (((zaehler*nenner2)+(zaehler2*nenner))/(nenner*nenner2));
      return sum;
    }
    //END OF - Method "Addition"
   
    //BEGIN OF - Method "subtraction"
    public int subtraction()
    {
      dif = (((zaehler*nenner2)-(zaehler2*nenner))/(nenner*nenner2));
      return dif;
    }
    //END OF - Method "subtraction"
   
    //BEGIN OF - Method "Multiplication"
    public int multiplication()
    {
      pro = ((zaehler*zaehler2)/(nenner*nenner2));
      return pro;
    }
    //END OF - Method "Multiplication"
   
    //BEGIN OF - Method "Division"
    public int division()
    {
      quo = ((zaehler/zaehler2)/(nenner/nenner2));
      return quo;
    }//END OF - Method "Division"
   
    return;
  }//END OF - Method "complete"
 }//END OF - public class bruch
Nun möchte ich die ganzen Methoden in einer Methode "complete()" schreiben. Wie?

Mein Java Editor meldet:
Zitat:
"bruch.java:25:4: illegal start of expression
public String enterBruch()"
"And he piled upon the whale´s white hump - a sum of all the rage and hate felt by his whole race.
If his chest had been a cannon, he would have shot his heart upon it."
  Mit Zitat antworten Zitat