This repository contains model, view and controller classes for solving Tower of Hanoi.
To install the application in IDEA, do the following:
- Clone the repository.
- Right click on class
TOHApp
. - Select
Run TOHApp.main()
You are now able to make changes to the project and run it again.
- Clone repository.
- Run
ant
default target (builds and runs the application).
Class TOHApp
contains method
static void solve (TowerOfHanoi toh, int numDiscs, Peg from, Peg to)
which you need to modify to solve the problems. The main()
of
this class calls method solve()
with correct parameters for
solving the problem, that is, moving all discs from rod A to rod C.
The version of solve()
in this repository is a feeble attempt to
solve this problem, and you need to replace it with your own
version. Still, the feeble version demonstrates the only external
methods you need to use:
class TowerOfHanoi
contains methodmove (Peg from, Peg to)
which moves top disc of rod
from
to rodto
. This may throw an exception if the move breaks the rules of Tower of Hanoi, but this exception is caught by the program. Possible exceptions are printed into console.
Copyright (C) 2020–2023 Jarmo Hurri, Aleksei Terin
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.