Add project files.
This commit is contained in:
17
FactoryPattern/Samples/Sample1.cs
Normal file
17
FactoryPattern/Samples/Sample1.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FactoryPattern.Samples;
|
||||
|
||||
public interface ISample1
|
||||
{
|
||||
string CurrentDateTime { get; set; }
|
||||
}
|
||||
|
||||
public class Sample1 : ISample1
|
||||
{
|
||||
public string CurrentDateTime { get; set; } = DateTime.Now.ToString();
|
||||
}
|
||||
22
FactoryPattern/Samples/Sample2.cs
Normal file
22
FactoryPattern/Samples/Sample2.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FactoryPattern.Samples;
|
||||
|
||||
public interface ISample2
|
||||
{
|
||||
int RandomValue { get; set; }
|
||||
}
|
||||
|
||||
public class Sample2 : ISample2
|
||||
{
|
||||
public int RandomValue { get; set; }
|
||||
|
||||
public Sample2()
|
||||
{
|
||||
RandomValue = Random.Shared.Next(1, 101);
|
||||
}
|
||||
}
|
||||
17
FactoryPattern/Samples/UserData.cs
Normal file
17
FactoryPattern/Samples/UserData.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FactoryPattern.Samples;
|
||||
|
||||
public interface IUserData
|
||||
{
|
||||
string? Name { get; set; }
|
||||
}
|
||||
|
||||
public class UserData : IUserData
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
46
FactoryPattern/Samples/Vehicles.cs
Normal file
46
FactoryPattern/Samples/Vehicles.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FactoryPattern.Samples
|
||||
{
|
||||
public interface IVehicle
|
||||
{
|
||||
string VehicleType { get; set; }
|
||||
|
||||
string Start();
|
||||
}
|
||||
|
||||
public class Car : IVehicle
|
||||
{
|
||||
public string VehicleType { get; set; } = "Car";
|
||||
|
||||
public string Start()
|
||||
{
|
||||
return "The Car has been Started.";
|
||||
}
|
||||
}
|
||||
|
||||
public class Van : IVehicle
|
||||
{
|
||||
public string VehicleType { get; set; } = "Van";
|
||||
|
||||
public string Start()
|
||||
{
|
||||
return "The Van has been Started.";
|
||||
}
|
||||
}
|
||||
|
||||
public class Truck : IVehicle
|
||||
{
|
||||
public string VehicleType { get; set; } = "Truck";
|
||||
|
||||
public string Start()
|
||||
{
|
||||
return "The Truck has been Started.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user