我对Java还是很陌生,我有一个项目,涉及从形容词和名词列表中随机取一个昵称,然后将其插入给定的名字和姓氏之间。我到处搜索(如果我错过了一个类似我的问题,请链接它,然后我将删除我的帖子),但是找不到适合我想要的答案的答案。
扫描仪读取的两个文件是很长的单词列表,每个单词前面都有数字。我希望扫描仪从每个列表中打印出一个随机形容词和一个随机名词。
这是我的代码:
import java.io.File;
import java.util.Scanner;
public class RandomNicknameGenerator
{
public static void main(String[] args) throws Exception
{
Scanner input = new Scanner(System.in);
String firstName;
String lastName;
System.out.println("What is your first name?");
firstName = input.nextLine();
System.out.println("What is your last name?");
lastName = input.nextLine();
File adjFile = new File("C:\\Users\\5010171\\Documents\\List
Folder\\AdjList.txt");
Scanner fs = new Scanner(adjFile);
while(fs.hasNextLine())
{
//not entirely sure what to put here
}
File nounFile = new File("C:\\Users\\5010171\\Documents\\List
Folder\\NounList.txt");
Scanner fs2 = new Scanner(nounFile);
while(fs2.hasNextLine())
{
//not entirely sure what to put here
}
}
}