import java.io.*;

public class oopbsp1 {

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

  private void test() {
    fluessigkeit f1;
    f1 = new fluessigkeit(123);
    f1.print();
    f1.addMenge(100);
    f1.print();
    f1.addMenge(-10);
    f1.print();

    fluessigkeit f2;
    f2 = new fluessigkeit("Wasser",145);
    f2.print();
    f2.subMenge(-200);
    f2.print();
  }

  public static void main(String argv[]) {
    oopbsp1  instanz = new oopbsp1();
    instanz.test();
    pause();
  }  // main

}


class  fluessigkeit {
   private String name;
   private int menge;

    // hier wird der gemeinsame Konstruktor aufgerufen
   public fluessigkeit(String name) {
     this(name,0);
   }

   public fluessigkeit(int menge) {
     this("",menge);
   }
   public fluessigkeit(String name, int menge) {
     this.name=name;
     if (menge>0)
      this.menge=menge;
     else
      this.menge=0;
   }


   public int getMenge() {
     return menge;
   }
   public void setMenge(int menge)  {
     if (menge>=0)
      this.menge=menge;
   }

   public String getName() {
     return name;
   }
   public void setName(String name) {
     this.name=name;
   }

   public void print() {
    System.out.println(
       "Name: "+getName()+
       " Menge:"+getMenge() );
   } // print

   public void addMenge(int value)  {
     if (value>0)
       menge+=value;
     else {
       throw new IllegalArgumentException(
         "Fehler");

     }
   }
   public void subMenge(int value)  {
     if (value>0) {
       if (value<=menge)
        menge-=value;
       else
        menge=0;
     }
     else {
     }
   }

}  // fluessigkeit
