所以我为我的java类创建了凯文培根游戏。培根游戏Java程序?
这些都是我得名字的文件使用
演员:
Leonardo Dicaprio
Susan Sarandon
Tom Hanks
Robert De Niro
Barack Obama
Helen Keller
Katharine Cornell
Helen Hayes
John Laughlin
Mark Zuckerberg
Joe Lipari
Welker White
的关系:
Susan Sarandon | Tom Hanks : Cloud Atlas
Tom Hanks | Kevin Bacon : Apollo 13
Leonardo Dicaprio | Kevin Bacon : This Boy's Life
Robert De Niro | Kevin Bacon : This Boy's Life
Barack Obama | Tom Hanks : the Road We've Traveled
Helen Keller | Katharine Cornell : Helen Keller in Her Story
Katharine Cornell | Helen Hayes : Stage Door Canteen
Helen Hayes | John Laughlin : Murder with Mirrors
John Laughlin | Kevin Bacon : Footloose
Mark Zuckerberg | Joe Lipari : Terms and Conditions May Apply
Joe Lipari | Welker White : Eat Pray Love
Welker White | Kevin Bacon : Lemon Sky
这是程序我现在有:
package Game;
import java.io.*;
import java.util.HashMap;
import java.util.Scanner;
import java.util.regex.Pattern;
/**
* @author
*
*/
public class BaconNumber
{
\t /**
\t * @param args
\t */
\t private HashMap<String,String> relationships;
\t private HashMap<String,String> actors;
\t
\t public static void main(String[] args)
\t
\t \t \t throws FileNotFoundException
\t {
\t \t Scanner input = new Scanner(new File("relationships"));
\t \t HashMap<String, String> relationships = new HashMap<String, String>();
\t \t
\t \t while (input.hasNextLine()) {
String[] columns = input.nextLine().split(Pattern.quote(" | "));
relationships.put(columns[0], columns[1]);
}
System.out.println(relationships);
\t \t }
\t
\t public BaconNumber()
\t {
\t \t relationships = new HashMap<String,String>();
\t \t actors = new HashMap<String,String>();
\t }
\t
\t public void printActors() throws FileNotFoundException
\t {
\t \t Scanner input = new Scanner(new File("actors"));
\t \t
\t \t while (input.hasNextLine())
\t \t {
\t \t System.out.println(input.nextLine());
\t \t }
\t }
\t
\t public int getBaconNumber(String actor , int number)
\t {
\t \t
\t \t if(actor == "Kevin Bacon")
\t \t {
\t \t \t return number;
\t \t }
\t \t
\t \t else
\t \t {
\t \t \t relationships.get(actor);
\t \t \t System.out.println(actor + " starred in " + relationships.value + "with" + relationships.value);
\t \t \t System.out.println(" The Bacon Number for " + actor + " is " + number);
\t \t \t return number; // fix this
\t \t }
\t \t
\t \t relationships.containsKey("Kevin Bacon")
// \t \t {
// \t \t \t number++;
// \t \t \t System.out.println(" The bacon number for" + actor + " is " + number);
// \t \t }
\t \t
// \t \t else
// \t \t {
// \t \t \t
// \t \t }
\t \t
\t \t
\t \t
\t }
}
我需要一些帮助,我getBaconNumber(),我需要的程序来查找演员和计算培根数当它终于到达凯文培根。
继承人什么PROFESOR被要求对这一计划: 1.查找演员的关系在你的HashMap 2.打印当前关系到控制台 3.Call中的关系与第二男主角递归方法(确保你增加你的培根数量)。
这种方法让我感到困惑,我无法完成它。
我需要它来打印这样的:
Helen Keller
Helen Keller starred in "Helen Keller in her story" with Katherine Cornell.
Katherine Cornell starred in " Stage Door Canteen " with Helen Hayes.
Helen Hays starred in "Murder with mirrors" with John Laughlin.
John Laughlin starred in " FootLoose" with Kevin Bacon.
The bacon number for Helen Keller is 4
如果任何人都可以在所有帮助,请我真的需要帮助,
我还需要BaconGame.java的其他帮助。它必须创建一个baconNumber对象,并按照helen keller示例所述管理游戏的输入和输出。在这一点上,只有程序 – Jay