Answer:
Explanation:
The following class code is written in Java and includes all of the required methods as requested in the question...
package sample;
class GasTank {
private double amount = 0;
private double capacity;
public GasTank(double initialAmount) {
this.capacity = initialAmount;
}
public void addGas(double addAmount) {
this.amount += addAmount;
if (amount > capacity) {
amount = capacity;
}
}
public void useGas(double subtractAmount) {
this.amount -= subtractAmount;
if (amount < 0) {
amount = 0;
}
}
public boolean isEmpty() {
return (amount < 0.1);
}
public boolean isFull() {
return (amount > capacity - 0.1);
}
public double getGasLevel() {
return amount;
}
public double fillUp() {
double difference = capacity - amount;
amount = capacity;
return difference;
}
}