第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

正在回答

1 回答

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
??? //public class Pet {
??? //??? public Pet(string name) {
??? //??????? _name = name;
?????? ?
??? //??? }
??? //??? protected string _name;
??? //??? public void PrintName() {

??? //??????? Console.WriteLine("Pet`s name is"+_name); ?
??? //??? }
??? //?? //虛方法
??? //??? virtual public void speak() {

??? //??????? Console.WriteLine(_name+"is speaking");
??? //??? }
??? //}
??? //結(jié)構(gòu)
??? struct fish {
??????? int weight;
??????? int price;
?? ?
??? }
??? //接口
??? interface ICatchMice {

??????? void catchMice();
??? }
??? interface IClimbTree {

??????? void climbTree();
??? }
?? abstract public class Pet
??? {
??????? public Pet(string name)
??????? {
??????????? _name = name;

??????? }
??????? protected string _name;
??????? public void PrintName()
??????? {

??????????? Console.WriteLine("Pet`s name is" + _name);
??????? }
??????? //抽象類,沒有函數(shù)體,無法實(shí)例化
??????? abstract public void speak();
??????? //{

??????????? //Console.WriteLine(_name + "is speaking");
??????? //}
??? }
??? //狗類
??? public class Dog : Pet {
??????? //靜態(tài)
??????? static int num;
??????? static Dog() {
??????????? num = 0;
?????? ?
??????? }
??????? //構(gòu)造函數(shù)
??????? public Dog(string name):base(name) {
??????????? //_name = name;
??????????? ++num;
?????? ?
??????? }
??????? new public void PrintName() {
??????????? Console.WriteLine("我的寵物是"+_name);
??????? }
??????? public override void speak()//重寫
??????? {
??????????? Console.WriteLine(_name + " is speaking"+" wow");
??????? }
??????? static public void ShowNum() {

??????????? Console.WriteLine("有"+num+"條狗");
??????? }
??? }
??? //貓類
??? public class Cat : Pet,ICatchMice,IClimbTree {
??????? //構(gòu)造函數(shù)
??????? public Cat(string name):base(name) {
??????????? //_name = name;
?????? ?
??????? }
??????? new public void PrintName() {
??????????? Console.WriteLine("我的寵物是"+_name);
??????? }
??????? public override void speak()
??????? {
??????????? Console.WriteLine(_name + "is speaking"+" meow");
??????? }
??????? public void catchMice() {

??????????? Console.WriteLine("catchmice");
??????? }
??????? public void climbTree() {
??????????? Console.WriteLine("climbtree");
??????? }
?? ?
??? }
??? //靜態(tài)類,方法擴(kuò)展
??? static class PetGuide{

??????? static public void HowToFeed(this Dog dog) {
??????????? Console.WriteLine("Play a vedio how to feed dog");
??????? }
?? ?
??? }
??? class Program
??? {
??????? static void Main(string[] args)
??????? {

??????????? //Dog Dog = new Dog();
??????????? //Dog.Name = "Jack";
??????????? //Dog.PrintName();
??????????? //Dog.speak();
??????????? //Pet Cat = new Cat();
??????????? //Cat.Name = "Tom";
??????????? //Cat.PrintName();
??????????? //Cat.speak();
??????????? Pet[] pets = new Pet[]{new Dog("Jack"),new Cat("Tom")};
??????????? for (int i = 0; i < pets.Length;i++ ) {
??????????????? pets[i].speak();
??????????? ?
??????????? }
??????????? Cat c = new Cat("Tom2");
??????????? IClimbTree climb = (IClimbTree)c;
??????????? c.catchMice();
??????????? climb.climbTree();
??????????? Dog a = new Dog("Jack1");
??????????? Dog.ShowNum();

??????????? Dog dog = new Dog("Tommy");
??????????? dog.HowToFeed();



??????? }
??? }
}

3 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕容3978549 提問者

非常感謝!
2018-01-02 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

可以把整個(gè)的代碼給我發(fā)一下嗎?

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)