1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- namespace Vehicle
- {
- class Vehicle
- {
- protected string Model;
- protected string Manufacturer;
- protected string Color;
-
- protected float EngineСapacity;
-
- protected float Fuel;
-
- protected int Power;
-
- protected int Distance;
-
- public void Move(int distance)
- {
- if (distance < 1)
- {
- return;
- }
- float DeltaFuel = EngineСapacity * 0.01f;
- int currentDistance = 0;
- while (currentDistance < distance)
- {
-
- if (Fuel < DeltaFuel)
- {
- Console.WriteLine("Закончилось горючее у " + Manufacturer + " " + Model);
- break;
- }
- Fuel -= DeltaFuel;
- Distance++;
- currentDistance++;
- }
- Console.WriteLine(Manufacturer + " " + Model + " проехал " + currentDistance + " метров из " + distance);
- }
- public void FuelUp(float value)
- {
- Fuel += value;
- }
- }
- }
|