コード例 #1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            ClassTicket ticket = new ClassTicket();

            ticket.AskData();
            ticket.ShowPrice(ticket);
            Console.WriteLine();

            Console.ReadKey();
        }
コード例 #2
0
        public void ShowPrice(ClassTicket ticket)
        {
            if (Age < 7)
            {
                Console.WriteLine("Price = " + Price * 0 + "€");
            }
            else if (Age >= 7 && Age <= 15)
            {
                Console.WriteLine("Price = " + Price * 0.5 + "€");
            }
            else if (Age >= 65)
            {
                Console.WriteLine("Price = " + Price * 0.5 + "€");
            }
            if (Age > 15 && Age < 65)
            {
                Console.Write("Soldier? [Y/N]: ");
                if (Console.ReadLine().ToUpper() == "Y")
                {
                    Console.WriteLine("Price = " + Price * 0.5 + "€");
                }

                else
                {
                    Console.Write("Mtk member? [Y/N]: ");
                    if (Console.ReadLine().ToUpper() == "Y")
                    {
                        Discount = 0.15f;
                    }
                    Console.Write("Student? [Y/N]: ");
                    if (Console.ReadLine().ToUpper() == "Y")
                    {
                        Discount = Discount + 0.45f;
                    }
                    Console.WriteLine($"Price = {Price - Price * Discount}€");
                }
            }
        }