Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package luke.idk;
- import java.io.BufferedWriter;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Random;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Luke
- * @version 1.00
- * Details: Creates an account choosing a random username and
- * password and stores details into a txt file for later use.
- *
- */
- public class AccountCreator {
- /**
- * Account log in details
- */
- private static String username = "";
- private static String password = "";
- /**
- * Number of accounts to make
- */
- private static String selection = JOptionPane.showInputDialog("How many accounts would you like created?");
- private static int amount = Integer.valueOf(selection);
- /**
- * Alphabet for assigning characters to the alphabet
- */
- private static char[] alphabets = "abcdefghijklmnopqrstuvwxyz".toCharArray();
- /**
- * Main method for executing the programme
- */
- public static void main(String[] args) throws IOException {
- for (int i = 0; i < amount; i++) {
- createUser(10);
- createPassword(10);
- login(username, password);
- logout();
- logDetails(username, password);
- System.out.println("-----------------------------------------------------------");
- username = "";
- password = "";
- }
- }
- /**
- * False login method for testing purposes
- */
- private static void login(String username, String password) {
- System.out.println("Username: " + username + " - " + "Password: " + password);
- System.out.println("Your dad is a homo please join niggerscape718 need staff");
- }
- /**
- * False log out method for testing purposes
- */
- private static void logout() {
- System.out.println("Logged out of account: " + username);
- }
- /**
- * Method for creating the username
- */
- private static void createUser(int length) {
- for (int i = 0; i < length; i++) {
- username += alphabets[new Random().nextInt(alphabets.length - 1)];
- }
- }
- /**
- * Method for creating the password
- */
- private static void createPassword(int length) {
- for (int i = 0; i < length; i++) {
- password += alphabets[new Random().nextInt(alphabets.length - 1)];
- }
- }
- /**
- * Method for writing account details to txt file.
- */
- private static void logDetails(String username, String password) throws IOException {
- String details = username + " " + password;
- System.out.println("Logging details: " + details);
- BufferedWriter fw2 = new BufferedWriter(new FileWriter(("accounts.txt"), true));
- fw2.write(details);
- fw2.newLine();
- fw2.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement