Towers Of Hanoi Java

后端 未结 2 1356
天涯浪人
天涯浪人 2021-01-26 17:52

This is a homework that I was working on. I have created 2 classes to play Towers of Hanoi. The first one is the basically a runner to run the actual game class.



        
2条回答
  •  无人及你
    2021-01-26 18:32

    You don't need the main-Function in the TowersOfHanoi class. Instead, replace your TowersRunner main(String args[]) method with

    public static void main(String[] args) {    
        System.out.println("Please enter the starting " + "number of discs to move:");
        Scanner scanner = new Scanner(System.in);
        int num_of_discs = scanner.nextInt();
        TowersOfHanoi.solve(num_of_discs, 'A', 'B', 'C');
    }
    

提交回复
热议问题