예제 #1
0
        static void Main(string[] args)
        {
            var energyCapacity = long.Parse(Console.ReadLine());

            var classJarvis = new Jarvis();

            classJarvis.EnergyCapacity = energyCapacity;

            while (true)
            {
                var input = Console.ReadLine().Split();

                if (input[0] == "Assemble!")
                {
                    break;
                }

                var component        = input[0];
                var energyConsuption = int.Parse(input[1]);
                var property1        = input[2];
                var property2        = input[3];

                switch (component)
                {
                case "Head":
                    var classHead = new Head()
                    {
                        Energy   = energyConsuption,
                        Iq       = int.Parse(property1),
                        Material = property2
                    };

                    classJarvis.AddHead(classHead);
                    break;

                case "Torso":
                    var classTorso = new Torso()
                    {
                        Energy    = energyConsuption,
                        Processor = double.Parse(property1),
                        Material  = property2
                    };

                    classJarvis.AddTorso(classTorso);
                    break;

                case "Arm":
                    var classArms = new Arms()
                    {
                        Energy  = energyConsuption,
                        Reach   = int.Parse(property1),
                        Fingers = int.Parse(property2)
                    };

                    classJarvis.AddArms(classArms);
                    break;

                case "Leg":
                    var classLegs = new Legs()
                    {
                        Energy   = energyConsuption,
                        Strength = int.Parse(property1),
                        Speed    = int.Parse(property2)
                    };

                    classJarvis.AddLegs(classLegs);
                    break;

                default: break;
                }
            }
            Console.WriteLine(classJarvis.ToString());
        }