title: java string toString with condition
body: <p>I have to write a PhonePlan object that will represent the type of plan that a customer has for his/her phone. So the object must keep track of the minutesAllowed (int), minutes used (int), dataAllowed (int), data used (int) and planType (boolean):</p>
  
  <pre><code>public class PhonePlan {
       int minutesAllowed;
       int minutesUsed;
       int dataAllowed;
       int dataUsed;
       boolean planType;
  }
  </code></pre>
  
  <p>I needed to write a constructor which has minutesAllowed, dataAllowed, and the planType as arguments which I did:</p>
  
  <pre><code>public PhonePlan (int ma, int da, boolean pt){
      this.minutesAllowed = ma;
      this.planType = pt;
      this.dataAllowed = da;
  }
  </code></pre>
  
  <p>And finally I have to write a string method that displays the plan depending on the type of plan.</p>
  
  <p>I also have to test my code with the following test program;</p>
  
  <pre><code>public class PlanTestProgram {
      public static void main(String args[]) {
  
          System.out.println(new PhonePlan(200, 2500000, false));
          System.out.println(new PhonePlan(250, 500000, true));
          System.out.println(new PhonePlan(300, 5000000, false));
          System.out.println(new PhonePlan(60, 1000000, false));
          System.out.println(new PhonePlan(30, 0, true));
      }
  </code></pre>
  
  <p>The first element being the minutesAllowed, the second one being the amount of dataAllowed and the third one is stating if planType is true of false.</p>
  
  <p>I tried many different things but I am not able to construct a toString() method that take into account if my planType is either true or false...</p>
  
  <p>My Attempt:</p>
  
  <pre><code>public String toString(){ 
      return ( "Regular(" + minutesAllowed + " minute," + dataAllowed 
                + "GB data) Monthly Plan with " 
                + getMinutesRemaining() + " minutes remaining and " 
                + getDataRemaining() + "KB remaining"); 
  }
  </code></pre>