// This will print out, for example: // Round # Height (in m) Speed (downwards, in m/s) // 0 850 150 // 1 650 200 // etc // // This is provided to you, but you'll need to add stuff elsewhere in order to make it work public void PrintHistory(MarsLanderHistory mlh) { Console.WriteLine("Round #\t\tHeight (in m)\t\tSpeed (downwards, in m/s)"); for (int i = 0; i < mlh.NumberOfRounds(); i++) { Console.WriteLine($"{i}\t\t{mlh.GetHeight(i)}\t\t{mlh.GetSpeed(i)}"); } }
public void PrintHistory(MarsLanderHistory mlh) { Console.WriteLine("Round #\t\tHeight (in m)\t\tSpeed (downwards, in m/s)"); for (int i = 0; i < mlh.NumberOfRounds(); i++) { Console.WriteLine("{0}\t\t{1}\t\t{2}", i, mlh.getHeight(i), mlh.getSpeed(i)); } }
// Clone is provided to you; it'll create a copy of the current history // Look for opportunities to use it elsewhere. public MarsLanderHistory Clone() { MarsLanderHistory copy = new MarsLanderHistory(); copy.rounds = new RoundInfo[this.rounds.Length]; copy.numRounds = this.numRounds; for (int i = 0; i < copy.numRounds; i++) { copy.rounds[i] = this.rounds[i]; } return(copy); }
// This will print out, for example: // Round # Height (in m) Speed (downwards, in m/s) // 0 850 150 // 1 650 200 // etc // // This is provided to you, but you'll need to add stuff elsewhere in order to make it work /// <summary> /// Print the history of the MarsLander descent with a header row and a row for /// each round. /// </summary> /// <param name="mlh">MarsLanderHistory object</param> public void PrintHistory(MarsLanderHistory mlh) { Console.WriteLine("Round #\t\tHeight (in m)\t\tSpeed (downwards, in m/s)"); int time = 0; // My failed attempt on trying to make this code work. // I'm wondering why mlh cannot touch the roundInfo nested class.... //for (int i = 0; i < mlh.NumberOfRounds(); i++) //{ // Console.WriteLine("{0}\t\t{1}\t\t{2}", i, mlh.GetHeight(), mlh.GetSpeed()); //} foreach (RoundInfo round in mlh) { time++; Console.WriteLine("{0}\t\t{1}\t\t\t\t{2}", time, round.GetHeight(), round.GetSpeed()); } }
// This will print out, for example: // Round # Height (in m) Speed (downwards, in m/s) // 0 850 150 // 1 650 200 // etc // // This is provided to you, but you'll need to add stuff elsewhere in order to make it work /// <summary> /// Print the history of the MarsLander descent with a header row and a row for /// each round. /// </summary> /// <param name="mlh">MarsLanderHistory object</param> public void PrintHistory(MarsLanderHistory mlh) { Console.WriteLine("Round #\t\tHeight (in m)\t\tSpeed (downwards, in m/s)"); foreach (RoundInfo round in mlh) { Console.WriteLine("{0}\t\t{1}\t\t{2}", round.GetTime(), round.GetHeight(), round.GetSpeed()); } }