C # interface

 1 //Public interface: "Animals" 

2 public interface IAnimal
3 {
4 void Behavior(); //behavior methods, describing the characteristics of various animals
5 }
6
7 //Class: Dog
8 public class Dog: IAnimal
9 {
10 public void Behavior()
11 {
12 Console.WriteLine(name() + " I sleep at night and be active during the day");
13 }
14 string name()
15 {
16 return "dog";
17 }
18 }
19
20 //Class: Cat
21 public class Cat: IAnimal
22 {
23 string info = "Cat";
24 public void Behavior()
25 {
26 Console.WriteLine(info + "I sleep during the day and be active at night") ;
27 }
28 }
29 //Simple application:
30 static void Main(string[] args)
31 {
32 IAnimal myDog = new Dog();
33 myDog.Behavior(); //< span style="color: #008000;">Output: "Dog I sleep at night and move around during the day"
34 IAnimal myCat = new Cat();
35 myCat.Behavior(); //< span style="color: #008000;">Output: "Cat I sleep during the day and be active at night"
36
37 }

 1 //Public interface: "Animals" 

2 public interface IAnimal
3 {
4 void Behavior(); //behavior methods, describing the characteristics of various animals
5 }
6
7 //Class: Dog
8 public class Dog: IAnimal
9 {
10 public void Behavior()
11 {
12 Console.WriteLine(name() + " I sleep at night and be active during the day");
13 }
14 string name()
15 {
16 return "dog";
17 }
18 }
19
20 //Class: Cat
21 public class Cat: IAnimal
22 {
23 string info = "Cat";
24 public void Behavior()
25 {
26 Console.WriteLine(info + "I sleep during the day and be active at night") ;
27 }
28 }
29 //Simple application:
30 static void Main(string[] args)
31 {
32 IAnimal myDog = new Dog();
33 myDog.Behavior(); //< span style="color: #008000;">Output: "Dog I sleep at night and move around during the day"
34 IAnimal myCat = new Cat();
35 myCat.Behavior(); //< span style="color: #008000;">Output: "Cat I sleep during the day and be active at night"
36
37 }

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3077 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.