Use Cases - YiJingFramework/YiJingFramework.Casting.ThreeCoins GitHub Wiki

You can find all the projects in the solution directory Example.

PaintingCasting

using System;
using YiJingFramework.Casting.ThreeCoins;

namespace PaintingCasting
{
    class Program
    {
        static void TossSixTimes(ThreeCoins threeCoins)
        {
            for (int i = 0; i < 6; i++)
            {
                threeCoins.TossAndDraw();
                Console.WriteLine($"{(threeCoins.Coin1.IsYangSideUp ? 3 : 2)} " +
                    $"{(threeCoins.Coin2.IsYangSideUp ? 3 : 2)} " +
                    $"{(threeCoins.Coin3.IsYangSideUp ? 3 : 2)}");
            }
        }
        static void Main()
        {
            var threeCoins = new ThreeCoins(new Paper());
            TossSixTimes(threeCoins);
            var paintings = threeCoins.Paper.GetPaintings();
            Console.WriteLine($"{paintings.Original} -> {paintings.Changed}");

            Console.WriteLine();

            // To use a new empty paper to record.
            threeCoins.Paper = new Paper();
            TossSixTimes(threeCoins);
            paintings = threeCoins.Paper.GetPaintings();
            Console.WriteLine($"{paintings.Original} -> {paintings.Changed}");
        }
    }
}

Coins

using System;
using YiJingFramework.Casting.ThreeCoins;

namespace Coins
{
    class Program
    {
        static void Main()
        {
            var coin = new Coin();
            // Random values:
            Console.WriteLine($"Before being tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Before being tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Before being tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Before being tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Before being tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Before being tossed: {coin.IsYangSideUp}");
            Console.WriteLine();

            Console.WriteLine(coin.Toss());
            // Same values:
            Console.WriteLine($"Tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Tossed: {coin.IsYangSideUp}");
            Console.WriteLine($"Tossed: {coin.IsYangSideUp}");
            Console.WriteLine();

            coin.HoldInHand();
            // Random values:
            Console.WriteLine($"After being held: {coin.IsYangSideUp}");
            Console.WriteLine($"After being held: {coin.IsYangSideUp}");
            Console.WriteLine($"After being held: {coin.IsYangSideUp}");
            Console.WriteLine($"After being held: {coin.IsYangSideUp}");
            Console.WriteLine($"After being held: {coin.IsYangSideUp}");
            Console.WriteLine($"After being held: {coin.IsYangSideUp}");
            Console.WriteLine();
        }
    }
}

Papers

using System;
using YiJingFramework.Casting.ThreeCoins;

namespace Papers
{
    class Program
    {
        static void Main()
        {
            var paper = new Paper();

            paper.Draw(YiJingFramework.Core.YinYang.Yang, false);
            Console.WriteLine(paper.GetPaintings());
            Console.WriteLine();
            // Output: (1, 1)

            paper.Draw(YiJingFramework.Core.YinYang.Yang, true);
            Console.WriteLine(paper.GetPaintings());
            Console.WriteLine();
            // Output: (11, 10)

            paper.Draw(YiJingFramework.Core.YinYang.Yin, false);
            Console.WriteLine(paper.GetPaintings());
            Console.WriteLine();
            // Output: (110, 100)

            paper.Draw(YiJingFramework.Core.YinYang.Yin, true);
            Console.WriteLine(paper.GetPaintings());
            Console.WriteLine();
            // Output: (1100, 1001)
        }
    }
}