-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pieza.cs
76 lines (65 loc) · 1.55 KB
/
Pieza.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
71
72
73
74
75
76
// File: Pieza.cs
// Author: Hendris
// Created: Sábado, 15 de Diciembre de 2007 07:42:23 p.m.
// Purpose: Definition of Class Pieza
using System;
using System.Collections.Generic;
public abstract class Pieza
{
private TiposPiezas tipo;
public TiposPiezas Tipo
{
get { return tipo; }
set { tipo = value; }
}
public enum Jugadores
{
blanco = 1,
negro = -1,
vacio = 0,
}
public enum TiposPiezas
{
Reina = 1,
peon = 0,
}
private Jugadores owner;
public Jugadores Owner
{
get { return owner; }
set { owner = value; }
}
public Pieza()
{
owner = Jugadores.vacio;
tipo = TiposPiezas.peon;
}
/// <summary>
/// Factory Method
/// </summary>
/// <param name="tipo">es el tipo de pieza, peon o reina del enum Jugadores</param>
/// <returns>retorna un objeto de las subclases peon o reina dependiendo del tipo</returns>
public static Pieza HacerPieza(TiposPiezas t)
{
Pieza rta;
if (t == TiposPiezas.peon)
{
rta = new Peon();
rta.tipo = t;
return rta;
}
if (t == TiposPiezas.Reina)
{
rta = new Reina();
rta.tipo = t;
return rta;
}
return null;
}
public abstract List<Movimiento> DestinosPosibles(int pos,int distancia);
public Pieza(Pieza old)
{
this.Owner = old.Owner;
this.Tipo = old.Tipo;
}
}