Problem Set 1: Introduction to Visual Studio .NET & C#
Problem Set 1: Introduction to Visual Studio .NET & C#
Problem Set 1: Introduction to Visual Studio .NET & C#
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Com S 430 Fall2005 Dr. Markus Lumpe<br />
<strong>Problem</strong> 4<br />
Implement the console application “TowersOfHanoi.exe” that uses the class library<br />
“TowersOfHanoiLib.dll”. In the Main function, create three Tower objects and s<strong>to</strong>re an<br />
initial number of disks on the first <strong>to</strong>wer by creating the appropriate disk objects and<br />
repeatedly calling the first Tower’s Add() method. The application should request a<br />
user input (using the methods Console.ReadLine() and Int32.Parse()) <strong>to</strong> set the initial<br />
number of disks. Furthermore, create a Priest object and call the method “MoveDisks”.<br />
The first argument is an ArrayList object. After the call of “MoveDisks” the ArrayList<br />
object will contain a list of strings that represent the performed moves. Print all strings<br />
contained in the ArrayList object using the “foreach” statement. The console application<br />
“TowersOfHanoi.exe” should produce the following output:<br />
Add the line<br />
Console.Read();<br />
as last statement <strong>to</strong> the Main function. You have <strong>to</strong> press any key <strong>to</strong> terminate the<br />
application. This might be useful, when debugging the program.<br />
5