Modify the CellPhone class so that it throws the appropriate exception when any of these errors occurs.
Question:
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());
}
}
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell