Skip to content

Commit e689731

Browse files
committed
Made some changes to UserDatabase
1 parent 1610c8c commit e689731

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/main/java/UserCreator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.io.FileNotFoundException;
2+
13
public interface UserCreator {
2-
void createUser();
4+
void createUser(String username, String password, String email);
35
}

src/main/java/UserDatabase.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
import java.io.File;
2+
import java.io.FileNotFoundException;
3+
import java.io.PrintWriter;
4+
import java.util.Scanner;
15
public class UserDatabase implements UserRegPresenter, UserCreator{
26
@Override
37
public boolean UserExists() {
8+
File accounts = new File("UserAccounts.csv");
9+
410
return false;
511
}
612

13+
// Creates a new user with a username and password, and an email address
14+
// The order is username, password, email address, verification status, status
15+
//
716
@Override
8-
public void createUser() {
9-
17+
public void createUser(String username, String password, String email) {
18+
File accounts = new File("UserAccounts.csv");
19+
try(PrintWriter out = new PrintWriter(accounts)){
20+
out.println(username + "," + password + "," + email + "," + "no" + "offline");
21+
out.flush();
22+
}catch (FileNotFoundException e){
23+
System.out.println("Error creating/writing to file");
24+
e.printStackTrace();
25+
};
1026
}
1127
}

0 commit comments

Comments
 (0)