PI06 i PI06-1. Docker definitions for MSSQL and Postgres. Data seeder/generator for countries and people. Entity Framework example with variants for Postgres and MSSQL
This commit is contained in:
39
SomeOfCSharpFeatures/Inheritance/Program.cs
Normal file
39
SomeOfCSharpFeatures/Inheritance/Program.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Inheritance;
|
||||
|
||||
Vehicle v = new Vehicle("BMW Isseta", 9.5);
|
||||
v.Start();
|
||||
|
||||
Car car = new ElectricCar("Nissan Leaf", 148, 5, 40)
|
||||
{
|
||||
Range = 270
|
||||
};
|
||||
Console.WriteLine("car model = " + car.Model);
|
||||
Console.WriteLine("car horse power = " + car.HorsePower);
|
||||
Console.WriteLine("car number of doors = " + car.Doors);
|
||||
if (car is ElectricCar electric)
|
||||
{
|
||||
Console.WriteLine("car battery = " + electric.BatteryCapacity);
|
||||
if (electric.Range.HasValue)
|
||||
{
|
||||
Console.WriteLine("car range = " + electric.Range);
|
||||
}
|
||||
}
|
||||
|
||||
car.BuckleSeatBelt();
|
||||
car.Start();
|
||||
car.Stop();
|
||||
|
||||
((Vehicle)car).Start();
|
||||
((Vehicle)car).Stop();
|
||||
|
||||
// objekt tipa Motocikl
|
||||
Motorbike moto = new Motorbike("Ural", 41, true);
|
||||
Console.WriteLine("motorbike model {0} ", moto.Model);
|
||||
Console.WriteLine("motorbike horse power = " + moto.HorsePower);
|
||||
Console.WriteLine($"motorbike has sidecar? = {moto.HasSidecar}");
|
||||
|
||||
moto.Start();
|
||||
moto.Stop();
|
||||
|
||||
((Vehicle)moto).Start();
|
||||
((Vehicle)moto).Stop();
|
||||
Reference in New Issue
Block a user