using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Threading.Tasks; using System.Windows.Forms; namespace TrackMaker4 { //This Class holds data to represent a train... // ...and functions to manipulate/retrieve it. public partial class Train { //Not really members of the class //Just indicate direction private const int LEFT = 0; private const int UP = 1; private const int RIGHT = 2; private const int DOWN = 3; //**Members of the class //Location private int tx; private int ty; private bool clockwise;//Whether or not the train is going clockwise private int speed;//Speed 0-6 //Every time a timer ticks, this counter increases until it reaches the speed //Strangely enough, the higer the speed, the slower it goes private int speed_cntr; private int id;//The Id of the strange private Color clr;//Color of train //These values need to be set so that the track can be mapped private int start_coming_from;//Where the strain started coming from private int start_going_to;//Where the train starts going to private bool stopped = true;//Whether the train is stopped or not //Constructors********************************// //Default constructor public Train() { this.clr = Color.Blue;//%% Maybe not default this this.id = 0; this.ty = 0; this.tx = 0; this.clockwise = true; // this.speed = 0; this.start_coming_from = DOWN; this.start_going_to = RIGHT; this.SpeedCntr = 0; this.Speed = 0; this.stopped = true; } //Copy Constructor public Train(Train cpy) { this.clr = cpy.Clr; this.id = cpy.Id; this.ty = cpy.Ty; this.tx = cpy.Tx; this.clockwise = cpy.Clockwise; this.start_coming_from = cpy.Coming_From; this.start_going_to = cpy.Going_To; this.SpeedCntr = cpy.SpeedCntr; this.speed = cpy.Speed; this.stopped = cpy.Stopped; } //Explicit value constructor public Train(int i, int x, int y,int coming_from,int going_to, int spd, bool ClckWs,Color color) { this.id = i; this.clr = color; this.tx = x; this.ty = y; //this.speed = spd; this.clockwise = ClckWs; this.start_coming_from = coming_from; this.start_going_to = going_to; this.SpeedCntr = 0; this.Speed = 0; this.stopped = true; } //End Constructors //Gets/Sets**********************************// public bool Stopped { get { return stopped; } set { stopped = value; } } public int Coming_From { get { return start_coming_from; } set { start_coming_from = value; } } public int Going_To { get { return start_going_to; } set { start_going_to = value;} } public Color Clr { get { return clr; } set { clr = value; } } public int Id { get { return id; } set { id = value; } } //Speed and SpeecCntr are explained above public int Speed { set { speed = value; } get { return speed; } } public int SpeedCntr { set { speed_cntr = value; } get { return speed_cntr; } } public bool Clockwise { set { clockwise = value; } get { return clockwise; } } //Location public int Tx//Train X { set { tx = value; } get { return tx; } } public int Ty//Train Y { set { ty = value; } get { return ty; } } //End Get/Sets **********************// } }