Skip to content

Instantly share code, notes, and snippets.

View hsynkrcf's full-sized avatar
🎯
Focusing

Hüseyin Karacif hsynkrcf

🎯
Focusing
View GitHub Profile
@hsynkrcf
hsynkrcf / Phone.cs
Created November 9, 2022 22:22
OCP
public class Phone
{
public PhoneType Type { get; set; }
}
public enum PhoneType
{
Iphone,
Samsung
}
public class Iphone : Phone
public class PhoneFactory
{
public void MakePhone(Phone phone)
{
switch (phone.Type)
{
case PhoneType.Iphone:
MakeIphone((Iphone)phone);
break;
case PhoneType.Samsung:
@hsynkrcf
hsynkrcf / Program.cs
Last active November 9, 2022 22:56
OCP
class Program
{
static void Main(string[] args)
{
PhoneFactory pf1 = new PhoneFactory();
pf1.MakePhone(new Iphone());
PhoneFactory pf2 = new PhoneFactory();
pf2.MakePhone(new Samsung());
Console.ReadLine();
}
@hsynkrcf
hsynkrcf / Phone.cs
Created November 10, 2022 00:27
YES OCP
public abstract class Phone
{
public abstract void Make();
}
public class Iphone : Phone
{
public override void Make()
{
Console.WriteLine("Iphone Created\n");
@hsynkrcf
hsynkrcf / PhoneFactory.cs
Created November 10, 2022 00:34
YES OCP
public class PhoneFactory
{
public void MakePhone(Phone phone)
{
phone.Make();
}
}
@hsynkrcf
hsynkrcf / Program.cs
Created November 10, 2022 00:40
YES OCP
class Program
{
static void Main(string[] args)
{
PhoneFactory pf1 = new PhoneFactory();
pf1.MakePhone(new Iphone());
PhoneFactory pf2 = new PhoneFactory();
pf2.MakePhone(new Samsung());
@hsynkrcf
hsynkrcf / HourSelector.cs
Created February 12, 2024 14:02
Automated Appointment Maker to Spor İstanbul by Selenium
using OpenQA.Selenium;
public static class HourSelector
{
public static (int, int)? SelectHour(IWebElement element, bool isSaturday)
{
const string satHour = "08:00 - 09:00"; // Weekends saturday time
const string eachHours = "18:30 - 19:30"; // Weekdays time
for (int repeater = 0; repeater <= 13; repeater++) // 13 repeater count
@hsynkrcf
hsynkrcf / BubbleSort.cs
Last active June 21, 2024 00:38
Bubble Sort Algorithm Performed On C#
public int[] BubbleSort(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - i - 1; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
@hsynkrcf
hsynkrcf / SelectionSort.cs
Last active June 21, 2024 00:38
Selection Sort Algorithm Performed On C#
public int[] SelectionSort(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
int minIdx = i;
for (int j = i + 1; j < n; j++)
{
if (arr[j] < arr[minIdx])
{
@hsynkrcf
hsynkrcf / QuickSort.cs
Created June 21, 2024 00:26
Quick Sort Algorithm Performed On C#
public int[] QuickSort(int[] arr, int low, int high)
{
if (low < high)
{
int pi = Partition(arr, low, high);
QuickSort(arr, low, pi - 1);
QuickSort(arr, pi + 1, high);
}
return arr;