COS101 2024_Term3 Practical2 - Protected View - Saved to this PC \( \checkmark \)
Flowers, J, Mr [28152409@s
Layout
References
Mailings
Review
View
Help
Corm
e Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View,
Enable Editing
1
2
3
4
5
6
7
8
9
10
11.
12
13
14.
15
16
Viewing
1 , where \( n \) is the number of disks.
Convert the following Towers Pseudo Code into Java. Name it student_numberp2s2t1.java
You can only vi
permissions to
Search
[??
\( \equiv \) CLASS TowerOfHanoi1 Untitled-1
0
CLASS TowerOfHanoil
METHOD run()
CALL moveTowers( \( 3, ' \mathrm{~A} \) ', 'B', 'C')
METHOD moveTowers ( \( n, A, B, C \) )
IF \( \mathrm{n}=\mathrm{I} 1 \) THEN
PRINT "Move a disk from rod " \( +\mathrm{A}+ \) " to rod " +C
ELSE
CALL moveTowers(n - 1, A, C, B)
PRINT "Move a disk from rod " + A + " to rod " + B
CALL moveTowers (n - 1, B, A, C)
METHOD main()
CREATE instance of TowerOfHanoil as objct
CALL objct.run()
END CLASS
Search