-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractClasses.cs
46 lines (39 loc) · 959 Bytes
/
AbstractClasses.cs
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
using System;
namespace hello_world {
//abstract class
public abstract class Control {
protected int xPos, yPos;
public Control(int xPos, int yPos) {
this.xPos = xPos;
this.yPos = yPos;
}
public virtual void Clear() {
}
public abstract void Draw();
}
//derived class
class Button : Control {
private string text;
public Button(int xpos, int ypos, string text) : base(xpos, ypos) {
this.text = text;
}
public override void Clear() {
xPos = 0;
yPos = 0;
Console.WriteLine($"xpos: {xPos}, ypos: {yPos}");
}
public override void Draw() {
Console.WriteLine($"Drawing the button at position... xpos: {xPos}, ypos: {yPos}");
}
}
class AbsDemo {
public AbsDemo() {
this.Demo();
}
public void Demo() {
Button loadingButton = new Button(500, 500, "Loading...");
loadingButton.Draw();
loadingButton.Clear();
}
}
}