-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
111 lines (101 loc) · 2.4 KB
/
Copy pathProgram.cs
File metadata and controls
111 lines (101 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System.Collections.Generic;
using LivingThings;
namespace Csharp
{
interface IExampleA
{
void F1();
int F2();
}
public abstract class ExampleB
{
string Name{get; set;}
public ExampleB() : this("<blank>")
{
System.Console.WriteLine("B constructor 0 param");
}
public ExampleB(string x)
{
System.Console.WriteLine("B constructor 1 param");
Name = x;
}
abstract public void MustImplement();
public void PrintAtt()
{
System.Console.WriteLine(Name);
}
}
public class A : ExampleB, IExampleA
{
public A() : base()
{
System.Console.WriteLine("child constructor");
}
public override void MustImplement()
{
System.Console.WriteLine("Some implementation.");
}
public void F1()
{
System.Console.WriteLine("This is F1 from interface");
}
public int F2()
{
System.Console.WriteLine("This is F2 from interface");
return 0;
}
}
public class Dog : Animal
{
public Dog()
{
Name = "";
}
public Dog(string Name)
{
this.Name = Name;
}
public override void MakeSound()
{
System.Console.WriteLine("Woof!");
}
}
public class Cat : Animal
{
public Cat()
{
Name = "";
}
public Cat(string _name)
{
Name = _name;
}
public override void MakeSound()
{
System.Console.WriteLine("Meow!");
}
}
class Program
{
// static void Main(string[] args)
// {
// List<Animal> animals =
// [
// new Dog("Rex"),
// new Cat("Whiskers"),
// new ("Generic")
// ];
// foreach (Animal a in animals)
// {
// a.PrintInfo();
// a.MakeSound();
// }
// System.Console.WriteLine(Animal.Count + " animals created.\n");
// A classA = new();
// // classA.F1();
// // int x = classA.F2();
// // classA.MustImplement();
// // classA.PrintAtt();
// }
}
}