-
Notifications
You must be signed in to change notification settings - Fork 0
/
October15Animal.cs
70 lines (69 loc) · 1.82 KB
/
October15Animal.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace Animal_Run
{
public abstract class Animal
{
public static Random RD { get; }
private int x;
private char icon;
private ConsoleColor color;
public String Name { set; get; }
public int X
{
set
{
if (value >= 0 && value < WindowWidth)
x = value;
//else throw new Exception("Error value : " + value);
}
get => x;
}
public char Icon
{
set
{
if ((int)value >= 0 && (int)value < 256)
icon = value;
else throw new Exception("Error icon : " + value);
}
get => icon;
}
public ConsoleColor Color
{
set
{
if ((int)value >= 0 && (int)value < 16)
color = value;
else throw new Exception("Error Color : " + value);
}
get => color;
}
public Animal(string nm = "UnNamed", int x = 0, ConsoleColor clr = ConsoleColor.Black, char ic = '*')
{
Name = nm;
X = x;
Color = clr;
Icon = ic;
}
public override string ToString()
{
return Name + "\t" + Icon + "\t" + Color + "\t" + X;//jamanakavor
}
public void Draw(bool draw = true)
{
ForegroundColor = draw ? Color : BackgroundColor;
SetCursorPosition(X, 5);
Write(Icon);
}
public abstract void Move();
static Animal()
{
RD = new Random();
}
}
}