Beispiel #1
0
 //Description: Resets the trains object's fields
 //Pre-Condition: None
 //Post-Condition: All fields set to 0 (or its type equivalent)
 public void ClearFields()
 {
     currentDockedStation = null;
     numPassengers        = 0;
     totalPassengers      = 0;
     profitGenerated      = 0;
 }
Beispiel #2
0
        private int totalPassengers;                   //total passengers that entered train in a given time frame

        //Description: Constructor method
        //Pre-Condition: None
        //Post-Condition: Generates passenger train object
        public PassengerTrain(string trainID, int speed)
        {
            this.trainID         = trainID;
            numPassengers        = 0;
            totalPassengers      = 0;
            currentDockedStation = null;
            profitGenerated      = 0;
            IsPassengerTrain     = true;
            IsFreightTrain       = false;
            this.speed           = speed;
            distanceTravelled    = 0;
        }
Beispiel #3
0
        private void button24_Click(object sender, EventArgs e)
        {
            Graph     railWay = new Graph();
            DataTable tracks  = trainconnect2.SelectDataTable("select track_id,coming_from,going_to from tracks");

            foreach (DataRow dr in tracks.Rows)
            {
                // MyFunction(dr["Id"].ToString(), dr["Name"].ToString());
                string           coming_from  = dr["coming_from"].ToString();
                string           going_to     = dr["going_to"].ToString();
                string           station_type = "";
                FreightStation   A;
                PassengerStation B;
                Hub C;
                Hub D;

                if (coming_from.Contains("STATION"))
                {
                    string    x       = coming_from;
                    DataTable station = trainconnect2.SelectDataTable("select station_type from station where station_id = \"" + x + "\"");
                    foreach (DataRow dt in station.Rows)
                    {
                        if (dt["station_type"].ToString().Contains("F"))
                        {
                            A = new FreightStation(x);
                        }
                        else if (dt["station_type"].ToString().Contains("P"))
                        {
                            DataTable pStation = trainconnect2.SelectDataTable("select ticket_price,range_on,range_off from station where station_id = \"" + x + "\"");

                            foreach (DataRow du in pStation.Rows)
                            {
                                B = new PassengerStation(x, Convert.ToInt32(du["ticket_price"]), Convert.ToInt32(du["range_on"]), Convert.ToInt32(du["range_on"]), Convert.ToInt32(du["range_off"]), Convert.ToInt32(du["range_off"]));
                            }
                        }
                    }
                }

                if (going_to.Contains("STATION"))
                {
                    string    x       = going_to;
                    DataTable station = trainconnect2.SelectDataTable("select station_type from station where station_id = \"" + x + "\"");
                    foreach (DataRow dt in station.Rows)
                    {
                        if (dt["station_type"].ToString().Contains("F"))
                        {
                            A = new FreightStation(x);
                        }
                        else if (dt["station_type"].ToString().Contains("P"))
                        {
                            DataTable pStation = trainconnect2.SelectDataTable("select ticket_price,range_on,range_off from station where station_id = \"" + x + "\"");

                            foreach (DataRow du in pStation.Rows)
                            {
                                B = new PassengerStation(x, Convert.ToInt32(du["ticket_price"]), Convert.ToInt32(du["range_on"]), Convert.ToInt32(du["range_on"]), Convert.ToInt32(du["range_off"]), Convert.ToInt32(du["range_off"]));
                            }
                        }
                    }
                }

                if (coming_from.Contains("HUB"))
                {
                    string x = coming_from;
                    C = new Hub(x);
                }

                if (going_to.Contains("HUB"))
                {
                    string x = going_to;
                    D = new Hub(x);
                }
            }
        }