-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShape.cs
More file actions
47 lines (41 loc) · 1.61 KB
/
Copy pathShape.cs
File metadata and controls
47 lines (41 loc) · 1.61 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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProgrammingLanguageIDE
{
public abstract class Shape:Shapes
{
protected Color colour; //shape's colour
protected int x, y;
public Shape()
{
//colour = Color.Red;
//x = y = 50;
}
public Shape(Color colour, int x, int y)
{
this.colour = colour; //shape's colour
this.x = x; //its x pos
this.y = y; //its y pos
//can't provide anything else as "shape" is too general
}
//the three methods below are from the Shapes interface
//here we are passing on the obligation to implement them to the derived classes by declaring them as abstract
public abstract void draw(Graphics g, bool fill, Color color);
//set is declared as virtual so it can be overridden by a more specific child version
//but is here so it can be called by that child version to do the generic stuff
//note the use of the param keyword to provide a variable parameter list to cope with some shapes having more setup information than others (in Java it is called varargs and uses the … notation
public virtual void set(params int[] list)
{
this.x = list[0];
this.y = list[1];
}
public override string ToString()
{
return base.ToString() + " " + this.x + "," + this.y + " : ";
}
}
}