Write a class Battery that models a rechargeable battery. A battery has capacity (instance variable) which can be drained. Capacity is a double value measured in milliampere hours (mAh) java

Respuesta :

A battery has capacity (instance variable) which can be drained. Capacity is a double value measured in milliampere hours (mAh) -A typical AA battery has a capacity of 2000 to 3000 mAh

Explanation:

public class Battery

{

     private double fullCharge;

     private double batteryCapacity;

public Battery(doublecapacity)

{

     battery Capacity = capacity;

     full Charge = capacity;

}

public void drain(double amount)

{

    battery Capacity = battery  Capacity - amount;

}

public void charge()

{

     battery Capacity = fullCharge;

}

public double get RemainingCapacity()

{

    return battery Capacity;

}

}