Esempio n. 1
0
        public void getPriceButton_Click(object sender, EventArgs e)
        {
            diamond = new Diamond();
            if (Write() && WriteColor())
            {
                diamond.Name       = inputName.Text;
                diamond.Weight     = Convert.ToDouble(inputWeight.Text.Replace(".", ","));
                diamond.CutQuality = Convert.ToDouble(inputCutQuality.Text.Replace(".", ","));
                int colorNumber = Convert.ToInt32(inputColor.Text);

                ColorNum color = new ColorNum();
                if (colorNumber == 1)
                {
                    color = ColorNum.Blue;
                }
                else if (colorNumber == 2)
                {
                    color = ColorNum.Yellow;
                }
                else
                {
                    color = ColorNum.None;
                }
                diamond          = new KindOfDiamond(diamond.Name, diamond.Weight, diamond.CutQuality, diamond.Cost(), color);
                priceOutput.Text = Convert.ToString(diamond.Cost());
            }
        }
Esempio n. 2
0
 public KindOfDiamond(string name, double weight, double cutQuality, double price, ColorNum color)
 {
     Name       = name;
     Weight     = weight;
     CutQuality = cutQuality;
     Price      = price;
     Color      = color;
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            string check = "";

            do
            {
                Diamond diamond = new Diamond();
                Console.WriteLine("Введите название алмаза:");
                diamond.Name = Console.ReadLine();
                Console.WriteLine("Введите вес(в каратах):");
                diamond.Weight = Input();
                Console.WriteLine("Введите качество огранки в баллах:");
                diamond.CutQuality = Input();

                Console.WriteLine("Выберите цвет алмаза из списка - \n1) Голубой \n2) Желтый \n3) Красный \n4) Белый");
                int      colorNumber = InputColor();
                ColorNum color       = new ColorNum();
                if (colorNumber == 1)
                {
                    color = ColorNum.Blue;
                }
                else if (colorNumber == 2)
                {
                    color = ColorNum.Yellow;
                }
                else
                {
                    color = ColorNum.None;
                }
                diamond = new KindOfDiamond(diamond.Name, diamond.Weight, diamond.CutQuality, diamond.Cost(), color);
                Console.WriteLine("Цена = " + diamond.Cost());
                Console.WriteLine();
                Console.WriteLine("Если хотите продолжить, введите 0, если хотите завершить работу, нажмите любую кнопку");
                check = Convert.ToString(Console.ReadLine());
            }while (check == "0");
            Console.ReadKey();
        }
Esempio n. 4
0
    public void Run()
    {
        var t      = ni();
        int caseNo = 1;

        while (t-- > 0)
        {
            int N, R, O, Y, G, B, V;
            N = ni();
            R = ni();
            O = ni();
            Y = ni();
            G = ni();
            B = ni();
            V = ni();

            var colors = new ColorNum[]
            {
                new ColorNum {
                    Charactor = 'R', Number = R
                },
                new ColorNum {
                    Charactor = 'Y', Number = Y
                },
                new ColorNum {
                    Charactor = 'B', Number = B
                },
            }.OrderByDescending(c => c.Number).ToArray();

            var ans = new char[N];

            bool failed = false;

            if (N == 1)
            {
                ans[0] = colors[0].Charactor;
            }
            else
            {
                for (int i = 0; i < N; i++)
                {
                    ans[i] = ' ';
                }

                for (int i = 0; i < N - 1; i += 2)
                {
                    if (colors[0].Number == 0)
                    {
                        break;
                    }
                    colors[0].Number--;
                    ans[i] = colors[0].Charactor;
                }

                for (int i = (N % 2 == 0 ? N - 1 : N - 2); i >= 0; i -= 2)
                {
                    if (ans[i] != ' ' || colors[1].Number == 0)
                    {
                        break;
                    }
                    colors[1].Number--;
                    ans[i] = colors[1].Charactor;
                }

                for (int i = 0; i < N; i++)
                {
                    if (colors[2].Number == 0)
                    {
                        break;
                    }
                    if (ans[i] == ' ')
                    {
                        colors[2].Number--;
                        ans[i] = colors[2].Charactor;
                    }
                }
            }

            failed = ans.Contains(' ');

            cout.WriteLine("Case #{0}: {1}", caseNo++, failed ? "IMPOSSIBLE" : new string(ans));
        }
    }