Question: Modify the CellPhone class so that it throws the appropriate exception when any of these errors occurs. public class CellPhone { private

Modify the CellPhone class so that it throws the appropriate exception when any of these errors occurs.  

 


public class CellPhone
{

   private String model;
   private String manufacturer;    // Manufacturer
   private double retailPrice; // Retail price
// Constructors

   public CellPhone(String m, String man, double price)
   {
      setModel(m);
      setManufacturer(man);
      setRetailPrice(price);
   }
   public CellPhone()
   {
      this("","",0.0);
   }
//Mutators
   public void setModel(String m)   {
      model = m;
   }
   public void setManufacturer(String man)
   {
      manufacturer = man;
   }
   
   public void setRetailPrice(double price)
   {
      retailPrice = price;
   }

   // Accessors
   public String getModel()
   {
      return model;
   }
   public String getManufacturer()
   {

      return manufacturer;
   }
   public double getRetailPrice()
   {

      return retailPrice;
   }



//the overirde
   @Override
   public String toString(){
      return String.format("Model: %-20sManufacturer: %-20sretail price: %10.2f%n",getModel(), getManufacturer(),
              getRetailPrice());

    }


}
 

 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!