logo

Crowdly

Mitu ringi saab sõita myCar enne, kui sel saab kütusepaak tühjaks? Car myC...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Mitu ringi saab sõita myCar enne, kui sel saab kütusepaak tühjaks?

Car myCar = new Car("Celica");

while (myCar.FuelTank != 0)

{

    myCar.Drive();

}

Console.WriteLine("Out of fuel.");

class Car

{

    private int fuelTank;

    private string model;

    public int FuelTank

    {

        get { return fuelTank; }

    }

    public string Model

    {

        get { return model; }

    }

    public Car(string _model)

    {

        fuelTank = 60;

        model = _model;

        Console.WriteLine($"The car {_model} is ready to drive.");

    }

    public void Drive()

    {

        Console.WriteLine("Vroooooom!");

        fuelTank = fuelTank - 12;

    }

}

More questions like this

Want instant access to all verified answers on moodle.tktk.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!