Guest User

Untitled

a guest
Jul 3rd, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileWriter;
  3. import java.io.IOException;
  4. import java.util.Scanner;
  5.  
  6. public class SLAccount2Test {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. Scanner key = new Scanner(System.in);
  11.  
  12. System.out.println("Enter username(10-20 characters): ");
  13. String username = "";
  14. boolean isValid = true;
  15. do {
  16. if (!isValid) {
  17. System.out.println("Username invalid.");
  18. }
  19. username = key.nextLine();
  20. } while (!(isValid = SecondLifeAccount2.goodUsername(username)));
  21. System.out.println("Username accepted.");
  22.  
  23. System.out.println("Enter password(6-16 characters, 1 uppercase, "
  24. + "1 lowercase, 1 digit): ");
  25. String password = "";
  26. do {
  27. if (!isValid) {
  28. System.out.println("Password invalid.");
  29. }
  30. password = key.nextLine();
  31. } while (!(isValid = SecondLifeAccount2.goodPassword(password)));
  32. System.out.println("Password accepted.");
  33.  
  34. System.out.println("Enter date of birth: ");
  35. int dob;
  36. do {
  37. if (!isValid) {
  38. System.out.println("Date of birth invalid.");
  39. }
  40. dob = key.nextInt();
  41. } while (!(isValid = SecondLifeAccount2.goodDob(dob)));
  42. System.out.println("Date of birth accepted.");
  43.  
  44. System.out.println("Enter secret question: ");
  45. String secretQuestion = key.next();
  46. System.out.println("Enter secret answer: ");
  47. String secretAnswer = key.next();
  48.  
  49. SecondLifeAccount2 user1 = new SecondLifeAccount2(username, password,
  50. dob, secretQuestion, secretAnswer);
  51. System.out.println("Your account information");
  52. System.out.println("Username: " + user1.getUsername());
  53. System.out.println("Password: " + user1.getPassword());
  54. System.out.println("Date of birth: " + user1.getDob());
  55. System.out.println("Secret question: " + user1.getSecretQuestion());
  56. System.out.println("Secret answer: " + user1.getSecretAnswer());
  57.  
  58. }
  59. try
  60. {
  61.  
  62. File makefile = new File("output.txt");
  63.  
  64. FileWriter fwrite = new FileWriter(makefile);
  65. fwrite.write("This is ");
  66. fwrite.write("a example");
  67. fwrite.write("of FileWriter");
  68. fwrite.flush();
  69. fwrite.close();
  70. }
  71. catch IOException e) {
  72. e.printStackTrace();
  73. }
  74. }
Add Comment
Please, Sign In to add comment