我制作了这个类,但我找不到制作测试类和实现我使用的方法的方法。
public class Battery
{
private float fullCharge = 3000;
private float batteryCapacity;
public Battery (float capacity)
{
if(capacity >0)
batteryCapacity = capacity;
fullCharge = capacity;
}
public void drain (float amount)
{
batteryCapacity = batteryCapacity -= amount;
}
public void charge (float amount)
{
batteryCapacity = fullCharge;
}
public float getRemainingCapacity()
{
return batteryCapacity;
}
}