コード例 #1
0
ファイル: PLFPet.cs プロジェクト: SkyLouna/PetLaForme
 //New instance of profile without id (Client)
 public PLFPet(PetType petType)
 {
     this.petID      = -1;
     this.petType    = petType;
     this.petName    = petType.ToString();
     this.sharePower = -1;
 }
コード例 #2
0
ファイル: Printer.cs プロジェクト: Applemelon/PetShop
        void Create()
        {
            PL("");
            PL("Enter the name of the Pet");
            string name = R();

            PL("");
            PL("Enter the number of the type of the Pet");
            PetType type = SelectPetType();

            PL("");
            PL("Enter the birthdate of the Pet");
            DateTime birthday = BirthdayFormat();

            PL("");
            PL("Enter the color of the Pet");
            string color = R();

            PL("");
            PL("Enter the name of the previous owner of the Pet");
            string previousowner = R();

            PL("");
            PL("Enter the price of the Pet");
            double price = ParseToDouble("Your entered value is not a number. Please enter the price of the Pet");

            //Pet pet = petService.New(name, type, birthday, color, previousowner, price);

            PL("");
            PL("You have created the following pet:");
            PL("Name: " + name);
            PL("Pet type: " + type.ToString());
            PL("Birth date: " + birthday.ToString("MM/dd/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture));
            PL("Color: " + color);
            PL("Previous owner: " + previousowner);
            PL("Price: " + price);
            PL("");
            PL("Do you want to add the Pet to the repository?");
            PL("Enter 1 to add the Pet to the repository");
            PL("Enter 2 to delete the Pet");

            string choice = R();

            switch (WhileParseInt(choice, "Please input a number between 1 and 2.", 2, 1))
            {
            case 1:
                //petService.Create(pet);
                PL("The Pet has been added to the repository.");
                break;

            case 2:
                PL("The Pet has not been added to the repository.");
                break;

            default:
                break;
            }
        }
コード例 #3
0
        /// <summary>
        /// Get pets for owners of a particular gender
        /// </summary>
        /// <param name="gender">Pet Owner gender</param>
        /// <param name="petType">Type of Owner pet</param>
        /// <returns></returns>
        public List <Pet> GetPetsByOwnerGenderAndPetType(Gender gender, PetType petType)
        {
            var genderStr  = gender.ToString();
            var petTypeStr = petType.ToString();

            return(PeopleList
                   .Where(person => person.Gender.ToString() == genderStr && person.Pets?.Count > 0)
                   .SelectMany(person => person.Pets)
                   .Where(pet => pet.Type.ToString() == petTypeStr)
                   .OrderBy(pet => pet.Name)
                   .ToList());
        }
コード例 #4
0
        public void Given_Instance_EnumValue_ShouldBe_Serialised_AsString(PetType petType)
        {
            var pet = this._fixture.Build <Pet>()
                      .With(p => p.PetType, petType)
                      .Create();


            var serialised = JsonConvert.SerializeObject(pet, this._settings);

            serialised.Should().ContainEquivalentOf(petType.ToString());
            serialised.Should().NotContainEquivalentOf("petType");
            serialised.Should().ContainEquivalentOf("\"type\":");
        }
コード例 #5
0
        /// <summary>
        /// Gets the type of the image for pet.
        /// </summary>
        /// <returns>The image for pet type.</returns>
        /// <param name="petType">Pet type.</param>
        public static UIImage GetImageForPetType(PetType petType)
        {
            UIImage image;

            try
            {
                //try to load image with pet type
                image = new UIImage($"Pet/{petType.ToString().ToLower()}.png");
            }
            catch
            {
                image = new UIImage("Pet/other.png");
            }

            return(image);
        }
コード例 #6
0
        public List <Pet> GetPetsByOwnerGender(PetType petType, GenderType gender)
        {
            List <Pet> pets = new List <Pet>();

            var people = this._peopleConnector.GetPeople();

            _log.Debug($"{people.Count} people returned from server");

            pets = people.Where(x => x.Gender == gender && x.Pets != null)
                   .SelectMany(x => x.Pets)
                   .Where(x => x.Type == petType)
                   .OrderBy(x => x.Name)
                   .ToList();

            _log.Debug($"Total pets as {petType.ToString()} for {gender.ToString()} owners are {pets.Count}");
            return(pets);
        }
コード例 #7
0
        public void Opposed_Type_Should_Return_Same_Opposed_Type()
        {
            //arrange
            PetType expectedResult = PetType.Dog;

            List <Person> persons = new List <Person>()
            {
                new Person("Dogs", opposedType: expectedResult)
            };

            Utils.SetSameOppossedToNone(persons);

            //Act
            PetType statusResult = persons[0].OpposedType;

            //Assert
            Assert.Equal(expectedResult.ToString(), statusResult.ToString());
        }
コード例 #8
0
        public void Same_Preffered_Type_Opposed_Should_Set_Opposed_To_None()
        {
            //arrange
            List <Person> persons = new List <Person>()
            {
                new Person("Dogs", preferredType: PetType.Dog, opposedType: PetType.Dog)
            };

            Utils.SetSameOppossedToNone(persons);

            //Act
            PetType statusResult = persons[0].OpposedType;

            //Assert
            PetType expectedResult = PetType.None;

            Assert.Equal(expectedResult.ToString(), statusResult.ToString());
        }
コード例 #9
0
        public static string ToDisplayName(this PetType petType)
        {
            if (petType == PetType.SmallBreedDog)
            {
                return("Small Dogs Breeds");
            }

            if (petType == PetType.AllDogs)
            {
                return("All Kinds of Dogs");
            }

            if (petType == PetType.OtherType)
            {
                return("Other Types of Pets");
            }

            return(petType.ToString());
        }
コード例 #10
0
 public override string ToString()
 {
     return($"ID = {ID.ToString()}, Name = {Name.ToString()}, Type = {PetType.ToString()}, BirthDate = {BirthDate.ToString()}, SoldDate = {SoldDate.ToString()}, Color = {Color.ToString()}, PreviousOwner = {PreviousOwner.ToString()}, Price = {Price.ToString()},\n");
 }
コード例 #11
0
ファイル: People.cs プロジェクト: nithinmi/Agl
        /// <summary>
        /// Get the pet names for a specific owner gender ordered alphabeticaly
        /// </summary>
        /// <param name="petType">Dog, Cat etc</param>
        /// <param name="gender">Male, Female</param>
        /// <param name="lstPeople">List of people with pet detailss</param>
        /// <returns></returns>
        public string[] GetPetNamesByOwnerGender(PetType petType, Gender gender, List <Dto.PeopleDto> lstPeople)
        {
            if (lstPeople == null)
            {
                throw new ArgumentNullException("lstPeople cannot be null");
            }

            var groupByGender = from p in lstPeople
                                group p.Pets by p.Gender
                                into g
                                select new { gender = g.Key, Data = g.ToList() };

            var genderGroup = groupByGender.FirstOrDefault(i => i.gender.ToLower().Equals(gender.ToString().ToLower()));

            if (genderGroup != null)
            {
                var genderData = genderGroup.Data;
                var petNames   = genderData.ToList().Where(e => e != null)
                                 .SelectMany(i => i.FindAll(x => x.Type.ToLower().Equals(petType.ToString().ToLower())))
                                 .OrderBy(f => f.Name)
                                 .Select(v => v.Name).ToArray();
                return(petNames.Length == 0 ? null : petNames);
            }
            return(null);
        }