module classes.BombaDeCombustivel;
import std.stdio;
class BombaDeCombustivel {
private:
char[] tipoCombustivel;
double valorLitro;
double quantidadeCombustivel;
public:
this() { }
this(char[] tipo, double valorLitro, double quantidadeCombustivel) {
this.tipoCombustivel = tipo;
this.valorLitro = valorLitro;
this.quantidadeCombustivel = quantidadeCombustivel;
}
void abastecerPorValor(double valor) {
double litros = valor / this.valorLitro;
this.quantidadeCombustivel += litros;
writefln("Foram abastecidos %.2f litros.", litros);
}
void abastecerPorLitro(double litros) {
double preco = litros * this.valorLitro;
this.quantidadeCombustivel += litros;
writefln("O cliente deve pagar R$ %.2f.", preco);
}
void alterarValor(double novoValor) {
this.valorLitro = novoValor;
}
void alterarCombustivel(char[] novoCombustivel) {
this.tipoCombustivel = novoCombustivel;
}
void alterarQuantidadeCombustivel(double novaQuantidade) {
this.quantidadeCombustivel = novaQuantidade;
}
void imprimir() {
writefln("Tipo de Combustível: %s\nValor do litro: R$ %.2f\nQuantidade de combustível: %.2f", this.tipoCombustivel, this.valorLitro, this.quantidadeCombustivel);
}
}
void main(char[][] args) {
BombaDeCombustivel b = new BombaDeCombustivel("Francisco", 2.3, 0);
b.abastecerPorLitro(20);
b.abastecerPorValor(10);
b.imprimir();
}