Esempio n. 1
0
        // GET: _07Object
        public ActionResult Index()
        {
            Person jack = new Person();

            //jack.Name = "Jack Wang";
            jack.Age    = 18;
            jack.Gender = true;
            jack.Height = 175.5M;
            jack.Weight = 60;
            jack.Speak();
            jack.Jump();
            jack.Walk(10);

            Person mary = new Person();

            mary.Name   = "Jack Lee";
            mary.Age    = 17;
            mary.Gender = false;
            mary.Height = 155.5M;
            mary.Weight = 40;
            mary.Speak(5);
            mary.Jump(6, 3);

            var avg = (jack.Age + mary.Age) / 2;

            Person john = new Person("John Lin", 20, true, 170, 64);

            Superman Clock = new Superman();

            Clock.Walk(500);
            Clock.Fly();


            return(View());
        }
Esempio n. 2
0
        // GET: _07Object
        public ActionResult Index()
        {
            Person Jack = new Person();

            Jack.Name   = "Jack Wang";
            Jack.Age    = 18;
            Jack.Gender = true;
            Jack.Height = 180.5M;
            Jack.Weight = 62;
            Jack.Speak();
            Jack.Jump();
            Jack.Walk(10);


            Person Mary = new Person();

            Mary.Age    = 18;
            Mary.Gender = false;
            Mary.Height = 160;
            Mary.Weight = 49.9M;
            Mary.Speak(5);
            Mary.Jump();

            var avg = (Jack.Age + Mary.Age) / 2;


            //有做建構子 就可以用一行結束 不用像上面寫這麼多行
            Person John = new Person("John Lin", 20, true, 170, 65);



            //繼承superman的東西
            Superman Clock = new Superman();

            Clock.Walk(100);
            Clock.Fly();
            Clock.Fly(3);

            return(View());
        }