コード例 #1
0
ファイル: BmiCalcForm.cs プロジェクト: BupTy03/BmiCalc
        /// <summary>
        /// Обработка события нажатия на кнопку "Рассчитать".
        /// </summary>
        private void OnCalculateButtonClicked(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                return;
            }

            BmiCalculator.CalculationResults calcResult;
            Human human;

            try
            {
                int         age      = Int32.Parse(ageTextBox.Text);
                int         heightCm = Int32.Parse(heightTextBox.Text);
                int         weightKg = Int32.Parse(weightTextBox.Text);
                HumanGender gender   = manRadioButton.Checked ? HumanGender.Male : HumanGender.Female;

                human      = new Human(age, heightCm, weightKg, gender);
                calcResult = BmiCalculator.Instance.Calculate(human);
            }
            catch (Exception)
            {
                ShowError("Упс, кажется что-то пошло не так :(");
                return;
            }

            using (var resultForm = new BmiResultForm(calcResult, human, BmiRecordsFileName))
            {
                resultForm.ShowDialog();
            }
        }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        detect          = GetComponent <HumanDetectAnimeState>();
        cur_anime_state = detect.state;

        gender = GetComponent <HumanGender>();

        SetLive2D();
    }
コード例 #3
0
        public Human(int age, int heightInCentimeters, int weightInKilograms, HumanGender gender)
        {
            CheckAge(age);
            CheckHeight(heightInCentimeters);
            CheckWeight(weightInKilograms);

            _age      = age;
            _heightCm = heightInCentimeters;
            _weightKg = weightInKilograms;
            _gender   = gender;
        }
コード例 #4
0
        public virtual string Prefix(bool shortPrefix = true, HumanGender gender = HumanGender.Unspecified)
        {
            List<string> prefixes = new List<string>();

            if (shortPrefix)
            {
                prefixes.Add("Dr.");

                if (gender == HumanGender.Unspecified || gender == HumanGender.Male)
                    prefixes.Add("Mr.");

                if (gender == HumanGender.Unspecified || gender == HumanGender.Female)
                    prefixes.AddRange(new[] { "Miss.", "Mrs." });
            }
            else
            {
                prefixes.Add("Doctor");

                if (gender == HumanGender.Unspecified || gender == HumanGender.Male)
                    prefixes.Add("Mister");

                if (gender == HumanGender.Unspecified || gender == HumanGender.Female)
                    prefixes.AddRange(new[] { "Missis", "Miss" });
            }

            return prefixes.ChooseAtRandom();
        }