Skip to content

Instantly share code, notes, and snippets.

public class SadService
{
public SadService()
{
Console.WriteLine("SadService Created");
}
public void Do()
{
Console.WriteLine("Oh oh oh oh oh oh oh oh...");
}
public class HappyService
{
public HappyService()
{
Console.WriteLine("HappyService create");
}
public void Do()
{
Console.WriteLine("Ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha");
}
using System;
namespace design_pattern
{
class Program
{
static void Main(string[] args)
{
// 原本寫法註解方便比較
// Toyote car1 = new Toyote();
public enum RacingType
{
Default = 0,
Toyote = 1,
Bens = 2,
Tezla = 3,
Blanket = 4,
Chair = 5,
Gororo = 6,
}
public interface IRacing
{
public void Skill();
}
public class Toyote: IRacing
{
private ISkill _skill;
public Toyote()
{
@cch12313
cch12313 / FactoryPattern-step1-1.cs
Created November 8, 2021 16:52
refactor by strategy pattern
public interface IRacing
{
public void Skill();
}
@cch12313
cch12313 / ObserverPattern1.cs
Last active October 24, 2021 15:42
Observer Pattern
using System;
using System.Collections.Generic;
namespace design_pattern
{
class Program
{
static void Main(string[] args)
{
var people1 = new People("Alvin");
@cch12313
cch12313 / StrategyPatternFinal.cs
Created October 17, 2021 04:37
Strategy Pattern
using System;
namespace design_pattern
{
class Program
{
static void Main(string[] args)
{
Toyote car1 = new Toyote();
Bens car2 = new Bens();
@cch12313
cch12313 / StrategyPattern3.cs
Last active October 17, 2021 04:23
Strategy Pattern
using System;
namespace design_pattern
{
class Program
{
static void Main(string[] args)
{
Toyote car1 = new Toyote();
Bens car2 = new Bens();
@cch12313
cch12313 / StrategyPattern2.cs
Created October 17, 2021 02:59
Strategy Pattern
using System;
namespace design_pattern
{
class Program
{
static void Main(string[] args)
{
Toyote car1 = new Toyote();
Bens car2 = new Bens();