打包应用;
import java.util.Scanner; 导入java.util.UUID;
公共类AccountThis { 私人静态扫描仪扫描仪;
public static void main( String[] args ) {
//name input
scanner = new Scanner( System.in );
System.out.print( "Type your name: " );
String nameInput = scanner.nextLine();
System.out.println("Hello" + " " + nameInput);
//deposit input
scanner = new Scanner( System.in );
System.out.print( "Type how much you want to deposit:" );
double depositInput = scanner.nextDouble();
System.out.println("you want to deposit" + " " + depositInput + "$");
public AccountThis(String id) {
System.out.println("ID Generated"
+ "Please Write it down :" + id);
}
class RandomStringUUID {}
public id = randID;{
UUID randID = UUID.randomUUID();
UUID randomUUIDString = randID;
System.out.println(randomUUIDString );
new AccountThis( nameInput, depositInput, id);
}
{
}
}
public AccountThis() {
System.out.println( "created an account." );
}
public AccountThis( String nameInput ) {
System.out.println( " created account with name " + nameInput );
}
public AccountThis(double depositInput) {
System.out.println(depositInput + "$" + "added to your account!" );
}
}
我是Java的新手,我正在尝试获取ID并使用一些文本将其分配给控制台,如您所见,如果您能帮我弄清楚我会很高兴,我会失败
btw我叫它id是因为我整夜都躺在上面,无法弄清楚。
答案 0 :(得分:0)
尝试此代码。一切正常
import java.util.Scanner;
import java.util.UUID;
public class AccountThis {
private static Scanner scanner;
public AccountThis(String nameInput) {
System.out.println(" created account with name " + nameInput);
}
public AccountThis() {
System.out.println("created an account.");
}
public AccountThis(double depositInput) {
System.out.println(depositInput + "$" + "added to your account!");
}
public AccountThis(String nameInput, double depositInput, String id) {
System.out.println(" created account with \n ID : " + id + ", \n name : " + nameInput);
System.out.println(depositInput + "$" + "added to your account!");
}
public static void main(String[] args) {
//name input
scanner = new Scanner(System.in);
System.out.print("Type your name: ");
String nameInput = scanner.nextLine();
System.out.println("Hello" + " " + nameInput);
//deposit input
scanner = new Scanner(System.in);
System.out.print("Type how much you want to deposit:");
double depositInput = scanner.nextDouble();
System.out.println("you want to deposit" + " " + depositInput + "$");
UUID randID = UUID.randomUUID();
String id=randID.toString();
new AccountThis(nameInput, depositInput,id);
}
}