我正在网上搜索几个小时,我无法找到适合我的正确答案。重新启动一个java控制台应用程序代码
所以..我做了一个名为'seabattle'的游戏 玩完那款游戏后,控制台出现问题再次播放。
System.out.println("Well done! " + whosturn.getName() + ". A ship down!");
System.out.println("Hurraaaaaayyyyy, All boats down!!");
System.out.println("Do you want to play this game again? (y/n) ");
input = scanner.next().toLowerCase();
if(input == "y"){
System.out.println("The game should start again now..");
System.out.println("Butttttttt, I don't know how to...");
}
else{
System.out.println("Thank you for player Battleships!");
System.out.println("See you next time ;)");
}
}
else{
FiredPosition.setDisplayValue('*');
System.out.println("Good job, you hit a ship!");
switchTurn();
}
如果用户在控制台中键入y。游戏应该重新开始。
我读了一些关于Main(args)或类似的东西..这对我没有用,因为这是另一个类。
我希望你们能帮助我?
Ciaoo
制作游戏课程的新对象并重新开始不是更简单吗?通过发送命令行参数而不是重新启动进程? – nunespascal 2013-04-08 11:10:04