所以这就是我到目前为止所做的:
public String[] findStudentInfo(String studentNumber) {
Student student = new Student();
Scanner scanner = new Scanner("Student.txt");
// Find the line that contains student Id
// If not found keep on going through the file
// If it finds it stop
// Call parseStudentInfoFromLine get the number of courses
// Create an array (lines) of size of the number of courses plus one
// assign the line that the student Id was found to the first index value of the array …Run Code Online (Sandbox Code Playgroud) 这是一个功课问题,我遇到了一些麻烦.
编写一个递归方法,确定String是否为十六进制数.为您的方法编写javadocs.如果每个字符为0或1或2或3或4或5或6或7或8或9或a或A或b或B或c或C或d或D或e,则字符串为十六进制数字或E或f或f.
目前,我只能看到测试这个,如果字符串0处的字符是他给我的这些值中的一个,那么它的一部分是十六进制.
任何提示或建议,以帮助我?
这是我到目前为止:`
public boolean isHex(String string){
if (string.charAt(0)==//what goes here?){
//call isHex again on s.substring(1)
}else return false;
}
Run Code Online (Sandbox Code Playgroud)
`
我想要做的是,如果用户点击回车键,程序应该抛出BadUserInputException.我的问题是,每当我按下回车键,它只是把我放在控制台的另一行,基本上什么都不做.
Scanner input = new Scanner(System.in);
System.out.println("Enter Student ID:");
String sID = null;
if (input.hasNextInt()==false){
System.out.println("Please re-check the student number inputted. Student number can only be digits.");
throw new BadUserInputException("Student number can not contain non-digits.");
}else if (input.next()==""){
throw new BadUserInputException("Student number can not be empty");
}
Run Code Online (Sandbox Code Playgroud)