Beispiel #1
0
        static void Main(string[] args)
        {
            Firearm pistol = new Firearm();

            pistol.Name    = "pistol";
            pistol.Sound   = "pop";
            pistol.Caliber = "9 mm";
            Console.WriteLine
                ("I am a "
                + pistol.Name
                + ", and I go "
                + pistol.Sound
                + " with a "
                + pistol.Caliber
                + ", and we have "
                + Firearm.GetCount().ToString()
                + " "
                + pistol.GetType().Name
                + "'s");

            Firearm rifle = new Firearm();

            rifle.Name    = "rifle";
            rifle.Sound   = "bang";
            rifle.Caliber = "7.62 mm";
            Console.WriteLine
                ("I am a "
                + rifle.Name
                + ", and I go "
                + rifle.Sound
                + " with a "
                + rifle.Caliber
                + ", and we have "
                + Firearm.GetCount().ToString()
                + " "
                + rifle.GetType().Name + "'s");

            Firearm shotgun = new Firearm();

            shotgun.Name    = "shotgun";
            shotgun.Sound   = "boom";
            shotgun.Caliber = "12 gauge";
            Console.WriteLine
                ("I am a "
                + shotgun.Name
                + ", and I go "
                + shotgun.Sound
                + " with a "
                + shotgun.Caliber
                + ", and we have "
                + Firearm.GetCount().ToString()
                + " " + shotgun.GetType().Name
                + "'s");
        }