コード例 #1
0
ファイル: Program.cs プロジェクト: kodefuguru/Presentations
        static Ninja CreateNinja(int piratesKilled, Clothing? clothes)
        {
            Ninja ninja = new Ninja();
            ninja.Name = "Sarutobi Sasuke";
            Weapon katana = new Weapon(WeaponType.Katana);
            Weapon shuriken = new Weapon(WeaponType.Shuriken);
            Weapon bow = new Weapon(WeaponType.Bow);
            List<Weapon> weapons = new List<Weapon>();
            weapons.Add(katana);
            weapons.Add(shuriken);
            weapons.Add(bow);
            ninja.Weapons = weapons;

            if (piratesKilled < 1)
            {
                ninja.PiratesKilled = 1;
            }
            else
            {
                ninja.PiratesKilled = piratesKilled;
            }

            if (clothes.HasValue)
            {
                ninja.Clothes = clothes.Value;
            }
            else
            {
                ninja.Clothes = Clothing.Shozoku;
            }

            return ninja;
        }
コード例 #2
0
ファイル: Clan.cs プロジェクト: kodefuguru/Presentations
        public void AddNinja(Ninja ninja)
        {
            if (ninjas.Count > 4)
            {
                throw new Exception("The clan cannot hold more ninjas.");
            }

            ninjas.Add(ninja);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Ninjas!!!");

            Person ninja = new Person("Mr.", "Nibbles");
            Person benny = new Person("Benny Bob", "McBob", 55);

            Ninja lydell = new Ninja("Lydell", "Ninja", 100, 150, 200);

            lydell.Birthday();


            benny.Birthday().Birthday().Birthday();
            Console.WriteLine(benny.Age);
        }
コード例 #4
0
ファイル: Clan.cs プロジェクト: kodefuguru/Presentations
        public Clan WithNinja(Ninja ninja)
        {
            this.ninjas.Add(ninja);

            return this;
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: kodefuguru/Presentations
        static void Main(string[] args)
        {
            Ninja ninja = CreateNinja(0, null);

            WriteNakedNinjas();
        }
コード例 #6
0
ファイル: Clan.cs プロジェクト: kodefuguru/Presentations
        public Clan WithNinja(Ninja ninja)
        {
            this.ninjas.Add(ninja);

            return(this);
        }