так сойдет?
using System;
namespace auto
{
class Program
{
public class Auto
{
private int _speed = 0;
private int _time = 0;
private string name_car = string.Empty;
public int Speed { get { return _speed; } set { _speed = value; } }
public int Time { get { return _time; } set { _time = value; } }
public string Name_car { get { return name_car; } set { name_car = value; } }
public void Drive()
{
Console.WriteLine(Speed * Time + " class Auto" + " name car: " + Name_car);
}
}
public class fastCar : Auto
{
public void fastDrive(int time, string name)
{
Console.WriteLine(Speed * time * 2 + " class fastCar" + " name car: " + name);
}
}
public class slowCar : Auto
{
public void slowDrive(int time, string name)
{
Console.WriteLine(Speed * time / 2 + " class slowCar" + " name car: " + name);
}
}
static void Main(string[] args)
{
fastCar x = new fastCar();
x.Speed = 100;
x.Time = 15;
x.Name_car = "fastCar-x";
x.Drive();
x.fastDrive(x.Time, x.Name_car);
slowCar y = new slowCar();
y.Speed = 100;
y.Time = 15;
y.Name_car = "slowCar-y";
y.Drive();
y.slowDrive(y.Time, y.Name_car);
Console.ReadLine();
}
}
}
п.с. логику лучше переделать под норму "don't repeat your self"
хотя бы вот так:
using System;
namespace auto
{
class Program
{
public class Auto
{
private int _speed = 0;
private int _time = 0;
private string name_car = string.Empty;
public int Speed { get { return _speed; } set { _speed = value; } }
public int Time { get { return _time; } set { _time = value; } }
public string Name_car { get { return name_car; } set { name_car = value; } }
public void Drive()
{
Console.WriteLine(Speed * Time + " class Auto" + " name car: " + Name_car);
}
}
public class fastCar : Auto
{
public void fastDrive()
{
Console.WriteLine(Speed * Time * 2 + " class fastCar" + " name car: " + Name_car);
}
}
public class slowCar : Auto
{
public void slowDrive()
{
Console.WriteLine(Speed * Time / 2 + " class slowCar" + " name car: " + Name_car);
}
}
static void Main(string[] args)
{
fastCar x = new fastCar();
x.Speed = 100;
x.Time = 15;
x.Name_car = "fastCar-x";
x.Drive();
x.fastDrive();
slowCar y = new slowCar();
y.Speed = 100;
y.Time = 15;
y.Name_car = "slowCar-y";
y.Drive();
y.slowDrive();
Console.ReadLine();
}
}
}