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); } }
static void Main(string[] args) { var pf = new PersonFactory(); var person = pf.CreatePerson("jan"); var person2 = pf.CreatePerson("jan2"); ReadKey(); }
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()); }
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)); }
/// <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); }
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"); }
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)); }
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)); }
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)); }
public ShouldSavePersonWithNoExtras(ISession session, PersonFactory personFactory) { var person = personFactory.CreatePerson("first last", "*****@*****.**", "this is my bio", Location.Austin); session.SaveOrUpdate(person); _personId = person.Id; }
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); }
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); }
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); }
/// <summary> /// Insert a person. /// </summary> public Person AddPerson(Person person) { var personDao = PersonFactory.CreatePersonDao(person); personDao = Insert(personDao); return(PersonFactory.CreatePerson(personDao)); }
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); }
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; }
public static Guest Define( [CallerLineNumber] int callerLineNumber = 0, [CallerMemberName] string callerMemberName = "") { var guest = PersonFactory.CreatePerson <Guest>( callerMemberName); return(guest); }
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); }
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; }
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); } }
public void TestMethod4() { AbstractPersonFactory <IPerson> a = new PersonFactory <IPerson>(); _person = a.CreatePerson(); _person.Move(); _person.Move(); }
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; }
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); }
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)); } }
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); }
//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(); }
public static Guest Define( int legacyID, [CallerLineNumber] int callerLineNumber = 0, [CallerMemberName] string callerMemberName = "") { var guest = PersonFactory.CreatePerson <Guest>( callerMemberName); guest.LegacyGuestID = legacyID; return(guest); }
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(); }
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); }
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); }