本文整理汇总了C#中Dog.Bark方法的典型用法代码示例。如果您正苦于以下问题:C# Dog.Bark方法的具体用法?C# Dog.Bark怎么用?C# Dog.Bark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dog
的用法示例。
在下文中一共展示了Dog.Bark方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Dog Pesho = new Dog();
Dog sharo = new Dog("Sharo","Ovchar");
sharo.Bark();
}
示例2: Main
public static void Main()
{
Dog sharo = new Dog("Sharo", "bolkonka");
Dog unnamed = new Dog();
unnamed.Name = "NewName";
sharo.Bark();
unnamed.Bark();
}
示例3: Main
public static void Main(string[] args)
{
Dog unnamed = new Dog();
Dog sharo = new Dog("Sharo", "Melez");
unnamed.Breed = "German Shepherd";
unnamed.Bark();
sharo.Bark();
}
示例4: Main
static void Main()
{
Dog sharo = new Dog("Sharo", "German Shepherd");
Dog mysteryDog = new Dog();
Dog lesserDog = new Dog("Lesser Dog", null);
sharo.Bark();
mysteryDog.Bark();
lesserDog.Bark();
}
示例5: Main
static void Main()
{
Dog dog = new Dog();
dog.Name = "Sharo";
Dog sharo = new Dog("Ivan", "German Shepherd");
dog.Bark();
sharo.Bark();
}
示例6: Main
public static void Main(string[] args)
{
Dog firstDog = new Dog();
Dog seconDog = new Dog("Bravo", "Husky");
firstDog.Breed = "Doberman";
firstDog.Bark();
seconDog.Bark();
}
示例7: Main
static void Main()
{
//обекти, инстанции на конкретния клас Dog
Dog unnamed = new Dog(null, "stray");
Dog sharo = new Dog("Sharo", "German shepherd");
//unnamed.Breed = "stray";
unnamed.Bark();
sharo.Bark();
}
示例8: The_dog_does_not_bark_for_0_treats
public void The_dog_does_not_bark_for_0_treats()
{
//Arrange
var dog = new Dog();
//Act
var actualBarks = dog.Bark(0);
var expectedBarks = new List<string>();
//Assert
Assert.IsTrue(actualBarks.Count == expectedBarks.Count, "Dog barked when it wasn't supposed to");
}
示例9: SubclassesCanModifyExistingBehavior
public void SubclassesCanModifyExistingBehavior()
{
var chico = new Chihuahua("Chico");
Assert.Equal(FILL_ME_IN, chico.Bark());
//Note that even if we cast the object back to a dog
//we still get the Chihuahua's behavior. It truly
//"is-a" Chihuahua
Dog dog = chico as Dog;
Assert.Equal(FILL_ME_IN, dog.Bark());
var fido = new Dog("Fido");
Assert.Equal(FILL_ME_IN, fido.Bark());
}
示例10: Main
static void Main(string[] args)
{
var mimi = new Cat();
mimi.Owner = "Pehso";
mimi.Name = "Mimi";
var stamat = new Dog("Stamat", "Minka");
stamat.Bark();
Lion koss = new Lion("Koss", 2, 300);
koss.Roar();
Bird sparrow = new Bird();
sparrow.Sing();
}
示例11: The_dog_does_not_bark_for_0_treats
public void The_dog_does_not_bark_for_0_treats()
{
//Arrange
var dog = new Dog();
//Act
var responses = dog.Bark(0);
var actualResponse = responses.FirstOrDefault();
string expectedResponse = null;
//Assert
Assert.AreEqual(expectedResponse, actualResponse);
Assert.IsTrue(responses.Count == 0, "The number of responses from the dog did not equal 0 as expected.");
}
示例12: The_dog_barks_once_for_1_treat
public void The_dog_barks_once_for_1_treat()
{
//Arrange
var dog = new Dog();
//Act
var responses = dog.Bark(1);
var actualResponse = responses.FirstOrDefault();
var expectedResponse = "Woof";
//Assert
Assert.AreEqual(expectedResponse, actualResponse);
Assert.IsTrue(responses.Count == 1, "The number of responses from the dog did not equal 1 as expected.");
}
示例13: The_dog_barks_once_for_1_treat
public void The_dog_barks_once_for_1_treat()
{
//Arrange
var dog = new Dog();
//Act
var actualBarks = dog.Bark(1);
var expectedBarks = new List<string>()
{
"Woof"
};
//Assert
Assert.IsTrue(actualBarks.Count == expectedBarks.Count, "Dog barked when it wasn't supposed to");
}
示例14: SubclassesCanModifyExistingBehavior
public void SubclassesCanModifyExistingBehavior()
{
var chico = new Chihuahua("Chico");
Assert.Equal("yip", chico.Bark());
//Note that even if we cast the object back to a dog
//we still get the Chihuahua's behavior. It truly
//"is-a" Chihuahua
/*
What happens to the original Dog class on this cast? Is it overwritten?
*/
Dog dog = chico as Dog;
// Why does chico, now as a dog, yip? It should WOOF! since it's now cast as a Dog.
Assert.Equal("yip", dog.Bark());
var fido = new Dog("Fido");
Assert.Equal("WOOF", fido.Bark());
}
示例15: Main
static void Main(string[] args)
{
Dog dog = new Dog("pesho", 5);
dog.Bark();
}