| | 53 | {{{ |
| | 54 | #!C# |
| | 55 | using System.IO; |
| | 56 | using System; |
| | 57 | |
| | 58 | class Program |
| | 59 | { |
| | 60 | static void Main() |
| | 61 | { |
| | 62 | Console.WriteLine("Hello, World!"); |
| | 63 | Animal animal = new Cat(); |
| | 64 | animal.who_am_i(); |
| | 65 | animal = new Kitten(); |
| | 66 | animal.who_am_i(); |
| | 67 | } |
| | 68 | } |
| | 69 | |
| | 70 | abstract class Animal |
| | 71 | { |
| | 72 | public abstract void who_am_i(); |
| | 73 | } |
| | 74 | |
| | 75 | class Cat:Animal |
| | 76 | { |
| | 77 | public override void who_am_i() { |
| | 78 | Console.WriteLine("I'm a Cat"); |
| | 79 | } |
| | 80 | } |
| | 81 | |
| | 82 | class Kitten:Cat |
| | 83 | { |
| | 84 | public override void who_am_i() { |
| | 85 | Console.WriteLine("I'm a Kitten"); |
| | 86 | } |
| | 87 | } |
| | 88 | }}} |