Beispiel #1
0
 public static string nameTrain(string state)
 {
     if (state == "nameTrain")
     {
         if (string.IsNullOrEmpty(Homepage.namingTextBox.Text.Trim()))
         {
             Homepage.ConsoleTextBox.Text = "Sorry! You have to give it a name!";
             return(state);
         }
         Random random = new Random();
         CurrentTrains.Add(new Train(Homepage.namingTextBox.Text.Trim(), CurrentStations[random.Next(0, CurrentStations.Count)]));
         Homepage.ConsoleTextBox.Text = "Awesome! We named your new Train: " + Homepage.namingTextBox.Text.Trim();
         Train.updateTrainInfoBox();
         Station.updateStationInfoBox();
         Homepage.namingTextBox.Text = null;
         return(null);
     }
     return(state);
 }
Beispiel #2
0
 public static string upgradeWhichTrain(string state)
 {
     if (state == "UpgradeWhichTrain")
     {
         if (string.IsNullOrEmpty(Homepage.namingTextBox.Text.Trim()))
         {
             Homepage.ConsoleTextBox.Text = "Sorry! You have to pick a train!";
             return(state);
         }
         var selectedTrainforUpgrade = CurrentTrains.Find(i => i.Name == Homepage.namingTextBox.Text.Trim());
         if (selectedTrainforUpgrade == null)
         {
             Homepage.ConsoleTextBox.Text = "We couldn't find a train named " + Homepage.namingTextBox.Text.Trim();
             return(state);
         }
         selectedTrainforUpgrade.TrainCapacity += selectedTrainforUpgrade.CapacityUpgradeAmount;
         Homepage.ConsoleTextBox.Text           = "Awesome! We have upgraded the train named " + Homepage.namingTextBox.Text.Trim() + " to a capacity of " + selectedTrainforUpgrade.TrainCapacity;
         Homepage.namingTextBox.Text            = null;
         return(null);
     }
     return(state);
 }
Beispiel #3
0
 public static string moveTrain(string state)
 {
     if (state == "MoveTrain")
     {
         if (string.IsNullOrEmpty(Homepage.namingTextBox.Text.Trim()))
         {
             Homepage.ConsoleTextBox.Text = "Sorry! You have to pick a Train";
             return(state);
         }
         TrainForMove = CurrentTrains.Find(i => i.Name == Homepage.namingTextBox.Text.Trim());
         if (TrainForMove == null)
         {
             Homepage.ConsoleTextBox.Text = "We couldn't find a train named " + Homepage.namingTextBox.Text.Trim();
             return(null);
         }
         Homepage.namingTextBox.Text  = null;
         Homepage.ConsoleTextBox.Text = "Alright, we found your Train! It is at station " + TrainForMove.TrainCurrentLocation.Name + " .Go ahead and add any packages or press 'Yes' to continue.";
         state = "PackageManagement";
         foreach (Package i in TrainForMove.TrainCurrentLocation.PackagesWaiting)
         {
             Homepage.packageSelectionDropDown.Items.Add(i.PackageType + "-" + i.PackageValue + "," + i.PackageDestinationStation.Name);
         }
         return(state);
     }
     else if (state == "MoveTrainDestination")
     {
         if (string.IsNullOrEmpty(Homepage.namingTextBox.Text.Trim()))
         {
             Homepage.ConsoleTextBox.Text += "Sorry! You have to pick a Station";
             return(state);
         }
         var selectedStationForMoving = CurrentStations.Find(i => i.Name == Homepage.namingTextBox.Text.Trim());
         if (selectedStationForMoving == null)
         {
             Homepage.ConsoleTextBox.Text = "We couldn't find a Station named " + Homepage.namingTextBox.Text.Trim();
             return(state);
         }
         var trackExists = CurrentTracks.Find(i => i.sourceStation == TrainForMove.TrainCurrentLocation && i.destinationStation == selectedStationForMoving);
         if (trackExists == null)
         {
             Homepage.ConsoleTextBox.Text = "Sorry, there is no track there. Transaction cancelled.";
             Homepage.namingTextBox.Text  = null;
             return(null);
         }
         TrainForMove.TrainCurrentLocation = selectedStationForMoving;
         Homepage.ConsoleTextBox.Text      = "You have moved!";
         Homepage.namingTextBox.Text       = null;
         Train.updateTrainInfoBox();
         Station.updateStationInfoBox();
         Homepage.packageSelectionDropDown.Items.Clear();
         Homepage.packageSelectionDropDown.SelectedItem = null;
         foreach (Package i in TrainForMove.Holding)
         {
             if (i.PackageDestinationStation == TrainForMove.TrainCurrentLocation)
             {
                 Bank.CurrentMoney           += i.PackageValue;
                 Homepage.ConsoleTextBox.Text = "Awesome! Packages have been successfully delivered!";
             }
         }
         TrainForMove.Holding.RemoveAll(i => i.PackageDestinationStation == TrainForMove.TrainCurrentLocation);
         Bank.updateMoneyBox();
         Train.updateTrainInfoBox();
         Station.updateStationInfoBox();
         state = null;
     }
     return(state);
 }