コード例 #1
0
ファイル: GameLogic.cs プロジェクト: Waznop/ElevatorPitch
    void Spawn()
    {
        if (Constants.Endless)
        {
            spawnTimer = spawnTime;
            spawnTime *= Constants.EndlessSpawnDecay;

            int from = Random.Range(Constants.MinNote, Constants.MaxNote + 1);
            int to   = Random.Range(Constants.MinNote, Constants.MaxNote + 1);
            while (to == from)
            {
                to = Random.Range(Constants.MinNote, Constants.MaxNote + 1);
            }

            floorManager.LightOn(from, true);
            PersonScript person = factory.CreatePerson();
            person.Appear(from, to);
            clients.Add(person);
        }
        else
        {
            int from = Constants.Level[curIdx];
            int to   = Constants.Level[curIdx + 1];

            string noteName = PitchManager.NoteToName(from);
            UpText.text   = noteName;
            DownText.text = noteName;
            floorManager.LightOn(from, true);
            PlayNote(from);
            PersonScript person = factory.CreatePerson();
            person.Appear(from, to);
            clients.Add(person);
        }
    }
コード例 #2
0
        static void Main(string[] args)
        {
            var pf      = new PersonFactory();
            var person  = pf.CreatePerson("jan");
            var person2 = pf.CreatePerson("jan2");

            ReadKey();
        }
コード例 #3
0
        private static void Main(string[] args)
        {
            var personFactory = new PersonFactory();
            var person1       = personFactory.CreatePerson("Alexandr");
            var person2       = personFactory.CreatePerson("Anna");

            Console.WriteLine(person1.ToString());
            Console.WriteLine(person2.ToString());
        }
コード例 #4
0
        public void CreatePerson_CreateSome_SetsRightId()
        {
            var personFactory = new PersonFactory();

            personFactory.CreatePerson("John");
            personFactory.CreatePerson("Jane");
            var person = personFactory.CreatePerson("Doe");

            Assert.That(person.Id, Is.EqualTo(2));
        }
コード例 #5
0
    /// <summary>
    /// The entry point of the program.
    /// </summary>
    private static void Main()
    {
        PersonFactory factory = new PersonFactory();

        Person theOneAndOnly = factory.CreatePerson("Батката", 27, Sex.Male);
        Console.WriteLine(theOneAndOnly);

        Person sheIsTheWoman = factory.CreatePerson("Мацето", 26, Sex.Female);
        Console.WriteLine(sheIsTheWoman);
    }
コード例 #6
0
    /// <summary>
    /// The entry point of the program.
    /// </summary>
    private static void Main()
    {
        PersonFactory factory = new PersonFactory();

        Person theOneAndOnly = factory.CreatePerson("Батката", 27, Sex.Male);

        Console.WriteLine(theOneAndOnly);

        Person sheIsTheWoman = factory.CreatePerson("Мацето", 26, Sex.Female);

        Console.WriteLine(sheIsTheWoman);
    }
コード例 #7
0
        static void Main(string[] args)
        {
            // use builder
            var cb = new CodeBuilder("Person").AddField("Name", "string").AddField("Age", "int");

            Console.WriteLine(cb);

            // use factory
            var pf = new PersonFactory();
            var p1 = pf.CreatePerson("Aro");
            var p2 = pf.CreatePerson("Vro");
        }
コード例 #8
0
ファイル: Person.cs プロジェクト: teovm/DesignPatternsCSharp
        public void Test()
        {
            var pf = new PersonFactory();

            var p1 = pf.CreatePerson("Juan");

            Assert.That(p1.Name, Is.EqualTo("Juan"));
            Assert.That(p1.Id, Is.EqualTo(0));

            var p2 = pf.CreatePerson("Antonio");

            Assert.That(p2.Id, Is.EqualTo(1));
        }
コード例 #9
0
        public void Test()
        {
            var pf = new PersonFactory();

            var p1 = pf.CreatePerson("Chris");

            Assert.That(p1.Name, Is.EqualTo("Chris"));
            Assert.That(p1.Id, Is.EqualTo(0));

            var p2 = pf.CreatePerson("Sarah");

            Assert.That(p2.Id, Is.EqualTo(1));
        }
コード例 #10
0
        public void Test()
        {
            var pf = new PersonFactory();

            var p1 = pf.CreatePerson("Fernando");

            Assert.That(p1.Name, Is.EqualTo("Fernando"));
            Assert.That(p1.Id, Is.EqualTo(0));

            var p2 = pf.CreatePerson("Taynara");

            Assert.That(p2.Id, Is.EqualTo(1));
        }
コード例 #11
0
        public ShouldSavePersonWithNoExtras(ISession session, PersonFactory personFactory)
        {
            var person = personFactory.CreatePerson("first last", "*****@*****.**", "this is my bio", Location.Austin);

            session.SaveOrUpdate(person);
            _personId = person.Id;
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: jaroslawwojcik/PersonsAge
        static void Main(string[] args)
        {
            do
            {
                Console.Clear();
                MainMenu();
                var option = Console.ReadKey(true).Key;
                switch (option)
                {
                case ConsoleKey.D1:
                    var createdPerson = _personFactory.CreatePerson();
                    _personsReopsitory.AddPerson(createdPerson);
                    break;

                case ConsoleKey.D2:
                    PrintAscending(_allPersons);

                    break;

                case ConsoleKey.D3:
                    Console.WriteLine("Please enter searched age");
                    var age = int.Parse(Console.ReadLine());
                    PrintOccuranceOfGivenAge(_allPersons, age);
                    break;

                case ConsoleKey.D4:
                    PrintAllPersons(_allPersons);
                    break;
                }
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
コード例 #13
0
    Person GetPerson(Type personType)
    {
        Person p = PersonFactory.CreatePerson(personType);

        // this code can't know what type of person was just created, because it depends on the parameter
        return(p);
    }
コード例 #14
0
        public void TestEventList()
        {
            List <Event> Agenda = new List <Event>();
            Event        event1 = new Event(201, "event201", Convert.ToDateTime(02 - 02 - 2020), Convert.ToDateTime(03 - 03 - 2020), "Lorem ipsum");
            Event        event2 = new Event(202, "event202", Convert.ToDateTime(03 - 03 - 2020), Convert.ToDateTime(04 - 04 - 2020), "Lorem ipsum");
            Event        event3 = new Event(203, "event203", Convert.ToDateTime(04 - 04 - 2020), Convert.ToDateTime(05 - 05 - 2020), "Lorem ipsum");
            Event        event4 = new Event(204, "event204", Convert.ToDateTime(05 - 05 - 2020), Convert.ToDateTime(06 - 06 - 2020), "Lorem ipsum");
            Event        event5 = new Event(205, "event205", Convert.ToDateTime(06 - 06 - 2020), Convert.ToDateTime(06 - 06 - 2020), "Lorem ipsum");

            Agenda.Add(event1);
            Agenda.Add(event2);
            Agenda.Add(event3);
            Agenda.Add(event4);
            Agenda.Add(event5);

            IEnumerable <AbstractPerson> Subordinates = new List <AbstractPerson>();

            AbstractPerson newStudent = PersonFactory.CreatePerson("Student200", "Student", "3", Agenda, 5, Subordinates);

            List <Event> Student200Agenda = Database.GetEventsList("Student200", Convert.ToDateTime(03 - 03 - 2020), Convert.ToDateTime(05 - 05 - 2020));

            List <Event> ResultAgenda = new List <Event>();

            ResultAgenda.Add(event2);
            ResultAgenda.Add(event3);
            ResultAgenda.Add(event4);

            Assert.AreEqual(ResultAgenda, Student200Agenda);
        }
コード例 #15
0
        /// <summary>
        /// Insert a person.
        /// </summary>
        public Person AddPerson(Person person)
        {
            var personDao = PersonFactory.CreatePersonDao(person);

            personDao = Insert(personDao);

            return(PersonFactory.CreatePerson(personDao));
        }
コード例 #16
0
    Person GetPerson()
    {
        Pilot p;

        p = (Pilot)PersonFactory.CreatePerson("Pilot");     // this code already knows to expect a Pilot, so why not just call CreatePilot or CreatePerson<Pilot>()?
        p = PersonFactory.CreatePilot();
        p = PersonFactory.CreatePerson <Pilot>();
        return(p);
    }
コード例 #17
0
        public ShouldSavePersonWithLinks(ISession session, PersonFactory personFactory, ISpecimenBuilder specimenBuilder)
        {
            var links  = specimenBuilder.CreateMany <LinkField>(_count).ToList();
            var fake   = specimenBuilder.Create <Person>();
            var person = personFactory.CreatePerson(fake.Name, fake.Email, fake.Bio, Location.Georgetown, null, links);

            session.SaveOrUpdate(person);
            _personId = person.Id;
        }
コード例 #18
0
ファイル: Guest.cs プロジェクト: CCRed95/CultureWars
        public static Guest Define(
            [CallerLineNumber] int callerLineNumber    = 0,
            [CallerMemberName] string callerMemberName = "")
        {
            var guest = PersonFactory.CreatePerson <Guest>(
                callerMemberName);

            return(guest);
        }
コード例 #19
0
    static void Main(string[] args)
    {
        AppDomain domain  = AppDomain.CreateDomain("NewDomain");
        Person    person1 = PersonFactory.CreatePerson("John Smith");
        Person    person2 = PersonFactory.CreatePersonInAppDomain("Jane Smith", domain);

        Console.WriteLine("Person: Name={0}, Domain={1}", person1.Name, person1.AppDomainName);
        Console.WriteLine("Person: Name={0}, Domain={1}", person2.Name, person2.AppDomainName);
    }
コード例 #20
0
        public ShouldSavePersonWithCategories(ISession session, PersonFactory personFactory, ISpecimenBuilder specimenBuilder)
        {
            var categories = specimenBuilder.CreateMany <CategoryField>(_count).ToList();
            var fake       = specimenBuilder.Create <Person>();
            var person     = personFactory.CreatePerson(fake.Name, fake.Email, fake.Bio, Location.SanMarcos, categories);

            session.SaveOrUpdate(person);
            _personId = person.Id;
        }
コード例 #21
0
        static void Main(string[] args)
        {
            // var point = Point.Factory.NewPolarPoint(3.56,2.78);
            // Console.WriteLine(point);

            // var machine = new HotDrinkMachine();
            // var drink = machine.MakedRink();
            // drink.Consume();
            var factory = new PersonFactory();

            factory.CreatePerson("Bob");
            factory.CreatePerson("Bob");

            foreach (Person p in factory.Persons)
            {
                System.Console.WriteLine(p);
            }
        }
コード例 #22
0
        public void TestMethod4()
        {
            AbstractPersonFactory <IPerson> a = new PersonFactory <IPerson>();

            _person = a.CreatePerson();

            _person.Move();
            _person.Move();
        }
コード例 #23
0
        public ShouldSavePersonWithLinksRemoved(ISession session, PersonFactory personFactory, ISpecimenBuilder specimenBuilder, IContainer container)
        {
            _container = container;
            var links  = specimenBuilder.CreateMany <LinkField>(_startCount).ToList();
            var fake   = specimenBuilder.Create <Person>();
            var person = personFactory.CreatePerson(fake.Name, fake.Email, fake.Bio, Location.SanMarcos, null, links);

            session.SaveOrUpdate(person);
            _personId = person.Id;
        }
コード例 #24
0
        static void Main(string[] args)
        {
            IPerson person  = PersonFactory.CreatePerson();
            IPerson sponsor = PersonFactory.CreatePerson();

            IMessageService messageService = MessageServiceFactory.CreateMessageService(person, sponsor);
            string          message        = messageService.SendMessage(person, sponsor);

            System.Console.WriteLine(message);
        }
コード例 #25
0
    private static void RegisterPersons(List <Person> persons)
    {
        int personNumber = int.Parse(Console.ReadLine());

        for (int i = 0; i < personNumber; i++)
        {
            string[] input = Console.ReadLine().Split();
            persons.Add(PersonFactory.CreatePerson(input));
        }
    }
コード例 #26
0
        public static Person MapEntityFromRequest(PersonInsertRequest request)
        {
            var person = PersonFactory.CreatePerson();

            person.FirstName = request.FirstName;
            person.LastName  = request.LastName;
            person.Email     = request.Email;
            person.Phone     = request.Phone;

            return(person);
        }
コード例 #27
0
        //private static void PrototypeTest()
        //{
        //    var john = new Person(new[] { "Rafael", "Oliveira" }, new Address("Rua Augusto Nunes", 221));
        //    var jane = (Person)john.Clone();

        //    jane.Address.HouseNumber = 123;

        //    // this doesn't work...
        //    // var jane = john;

        //    // but clone is typically shallow copy
        //    jane.Names[0] = "Jane";

        //    WriteLine(john);
        //    WriteLine(jane);
        //}

        private static void FactoryExerciseTest()
        {
            var personList = new[] { "Fulano", "Beltrano", "Ciclano" };
            var factory    = new PersonFactory();

            foreach (var p in personList)
            {
                factory.CreatePerson(p);
            }

            factory.Show();
        }
コード例 #28
0
ファイル: Guest.cs プロジェクト: CCRed95/opieandanthonylive
        public static Guest Define(
            int legacyID,
            [CallerLineNumber] int callerLineNumber    = 0,
            [CallerMemberName] string callerMemberName = "")
        {
            var guest = PersonFactory.CreatePerson <Guest>(
                callerMemberName);

            guest.LegacyGuestID = legacyID;

            return(guest);
        }
コード例 #29
0
        static void Main(string[] args)
        {
            #region 1

//            var factory = new FlyweightFactory();
//            var f1 = factory.GetFlyweight("x");
//            var f2 = factory.GetFlyweight("y");
//            var f3 = factory.GetFlyweight("z");
//            var f4 = new UnShareFlyweight();
//            var num = 10;
//            f1.Operation(--num);
//            f2.Operation(--num);
//            f3.Operation(--num);
//            f4.Operation(--num);

            #endregion

            #region 2

            var pf = new PersonFactory();
            pf.CreatePerson(PersonType.Doctor, "孙小双").Say();
            pf.CreatePerson(PersonType.Student, "万星辉").Say();
            pf.CreatePerson(PersonType.Teacher, "李娟娟").Say();
            pf.CreatePerson(PersonType.Doctor, "李怡然").Say();
            pf.CreatePerson(PersonType.Teacher, "鲁冰冰").Say();
            pf.CreatePerson(PersonType.Teacher, "尹晓畅").Say();

            #endregion
            Console.ReadKey();
        }
コード例 #30
0
        private static Person GetUserInfo()
        {
            Console.WriteLine("Please enter your first name:");
            var firstName = Console.ReadLine();

            Console.WriteLine("Please enter your last name:");
            var lastName = Console.ReadLine();

            Console.WriteLine("Please enter your age:");
            int.TryParse(Console.ReadLine(), out var age);

            var person = PersonFactory.CreatePerson(firstName, lastName, age);

            return(person);
        }
コード例 #31
0
        public void CreatePersonTest()
        {
            //Arrange
            var systemUnderTest = new PersonFactory();

            //Act
            IPerson result = systemUnderTest.CreatePerson(k_personName, k_personAddress, k_personPhone, k_personIsActive);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result.Name, k_personName);
            Assert.AreEqual(result.Address, k_personAddress);
            Assert.AreEqual(result.Phone, k_personPhone);
            Assert.AreEqual(result.IsActive, k_personIsActive);
        }