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:
Boris Milašinović
2026-04-19 16:49:07 +02:00
parent 44a663e170
commit 6f56d107a2
89 changed files with 7305 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using System;
namespace Inheritance;
public class Car : Vehicle
{
public int Doors { get; set; }
public string Color { get; set; } = "White";
public Car(string model, double horsePower, int doors)
: base(model, horsePower)
{
Console.WriteLine($"Creating car {model}");
this.Doors = doors;
}
public void BuckleSeatBelt()
{
Console.WriteLine("Car {0} - seat belt buckled", Model);
}
public override void Start()
{
Console.WriteLine("Start Car " + Model);
}
public new void Stop()
{
Console.WriteLine("Stop Car " + Model);
}
}

View File

@@ -0,0 +1,13 @@
namespace Inheritance;
public class ElectricCar : Car
{
public int BatteryCapacity { get; set; }
public int? Range { get; set; }
public ElectricCar(string model, double horsePower, int doors, int batteryCapacity) :
base(model, horsePower, doors)
{
this.BatteryCapacity = batteryCapacity;
}
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,18 @@
using System;
namespace Inheritance;
public class Motorbike : Vehicle
{
public bool HasSidecar { get; set; }
public Motorbike(string model, double horsePower, bool sidecar)
: base(model, horsePower)
{
Console.WriteLine($"Creating car {model}");
this.HasSidecar = sidecar;
}
public override void Start()
{
Console.WriteLine("Start Motorbike " + Model);
}
}

View 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();

View File

@@ -0,0 +1,26 @@
using System;
namespace Inheritance;
public class Vehicle
{
public string Model { get; private set; }
public double HorsePower { get; set; }
public Vehicle(string model, double horsePower)
{
Console.WriteLine("Creating vehicle " + model);
this.Model = model;
this.HorsePower = horsePower;
}
public void Stop()
{
Console.WriteLine("Stop vehicle " + Model);
}
public virtual void Start()
{
Console.WriteLine("Start vehicle " + Model);
}
}