murray
2012-11-21 17:35:58 UTC
disks are all of different sizes. Legal configuration is if the disks are distributed on a tower so that on any tower a larger disk is never on a smaller disk. The program prints out a series of moves to transform the initial configuration to the final configuration.
my code so far:
public class TOfHanois {
char config1[]=new char[10];
char config2[]=new char[10];
public static void move(char config1s[], char config2s[],int ndisks)
{
System.out.println("done");
}
public static void main(String [] args)
{
Scanner scan=new Scanner(System.in);
Scanner scan2=new Scanner(System.in);
int disks;
System.out.println("Please enter the number of disks in both towers: ");
disks=scan.nextInt();
char [] config1 = new char[disks];
config1 = getInput();
//String []letters=new String[disks];
//char input;
//char[] getInput();
///String input1=config1.toString();
char [] config2 = new char[disks];
config2 = getInput();
String s=new String(config1);
String s2=new String(config2);
System.out.println("first char in array is: "+config1[4]);
if(s.compareTo(s2)==0)
{
System.out.println("done");
}
else{
System.out.println("continue");
}
}
static char[] getInput() {
Scanner scan = new Scanner(System.in);
System.out.print("Enter string: ");
String str = scan.nextLine();
return str.toCharArray();
}
}