question archive Define the missing method

Define the missing method

Subject:Computer SciencePrice:2.85 Bought3

Define the missing method. Use "this" to distinguish the local member from the parameter name.

// ===== Code from file CablePlan.java =====
public class CablePlan {
   private int numDays;

   // FIXME: Define setNumDays() method, using "this" implicit parameter.
   public void setNumDays(int numDays) {

      /* Your solution goes here */

      return;
   }

   public int getNumDays() {
      return numDays;
   }
}
// ===== end =====

// ===== Code from file CallCablePlan.java =====
public class CallCablePlan {
   public static void main (String [] args) {
      CablePlan house1Plan = new CablePlan();

      house1Plan.setNumDays(30);
      System.out.println(house1Plan.getNumDays());

      return;
   }
}
// ===== end =====

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

public class CablePlan {
   private int numDays;
   // FIXME: Define setNumDays() method, using "this" implicit parameter.
   public void setNumDays(int numDays) {
   /* Your solution goes here */
       this.numDays=numDays;
         
   return;
   }
   public int getNumDays() {
   return numDays;
   }
}


public class CallCablePlan {
public static void main (String [] args) {
CablePlan house1Plan = new CablePlan();
house1Plan.setNumDays(30);
System.out.println(house1Plan.getNumDays());
return;
}
}

OUTPUT:30

Related Questions