1: | Assume that you are writing the source code from which three different program versions will be compiled a Standard Version, a Professional Version, and an Enterprise Version. In this case, the program simply contains three different WriteLine statements that write the following three lines: A: "This is the standard version" B: "This is the professional version" C: "This is the enterprise version" The Standard Version only prints line A, the Professional Version only prints line B, and the Enterprise Version only prints line C. Use preprocessor directives so that you can easily control (without deleting and adding WriteLine statements, but instead by defining and undefining identifiers) which of the three WriteLine statements is being included in the program. |
2: | Use document comments and the <summary> and <remarks> tags to document the following program. Make sure you provide descriptions for all classes and methods. Use the compiler to extract the corresponding XML document. using System; class Calculator { public static int Sum(int x, int y) { return x + y; } public static int Product(int x, int y) { return x * y; } } class RocketScientist { public static void Main() { Console.WriteLine("Estimated time to go to Mars: { 0} ", EstimatedTimeToMars(23)); } public static uint EstimatedTimeToMars(int x) { return (uint) (Calculator.Sum(x, 24) + Calculator.Product(x, 21)); } } |
3: | Consider the source code in Listing 21.4. Listing 21.4 Train.csusing System; class Train { private uint distance = 0; public void MoveBySteam(uint addDistance) { Console.WriteLine("Moving { 0} kilometers by steam", addDistance); distance += addDistance; } public void MoveByElectricity(uint addDistance) { Console.WriteLine("Moving { 0} kilometer by electricy", addDistance); distance += addDistance; } public void TestingDistance() { Console.WriteLine("Testing. distance instance variable: { 0} ", distance); } } class Tester { public static void Main() { Train orientExpress = new Train(); orientExpress.MoveBySteam(100); orientExpress.MoveByElectricity(200); orientExpress.TestingDistance(); } }
|