/// <summary> /// Determine the price of a boat license based on the motor's horse power. /// </summary> private static void DoExe5() { Console.WriteLine("Exercise 5"); const int STARTING_NUM = 201601; BoatLicense[] license = new BoatLicense[3]; int x; for (x = 0; x < license.Length; ++x) { license[x] = new BoatLicense(); license[x].LicenseNum = (x + "" + STARTING_NUM); } license[0].State = "WI"; license[1].State = "MI"; license[2].State = "MN"; license[0].MotorSizeInHP = 30; license[1].MotorSizeInHP = 50; license[2].MotorSizeInHP = 100; for (x = 0; x < license.Length; ++x) { Display(license[x]); } // Pause until the user hits enter. Console.ReadKey(); }
/// <summary> /// Display a boat license. /// </summary> /// <param name="bl">The <see cref="BoatLicense"/> boat license.</param> private static void Display(BoatLicense bl) { Console.WriteLine($"Boat #{bl.LicenseNum} from {bl.State} has a {bl.MotorSizeInHP} HP motor."); Console.WriteLine($"\t The price for the license is {bl.Price:C}"); }