Skip to content

Commit 5c4b5c9

Browse files
committed
added changes made to another branch and resolved conflicts
1 parent e4efd7e commit 5c4b5c9

File tree

2 files changed

+2
-51
lines changed

2 files changed

+2
-51
lines changed

src/main/java/UserDatabase.java

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,23 @@
33
import java.util.List;
44
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList{
55
File accounts;
6-
<<<<<<< HEAD
6+
List<User> accountList;
77
public UserDatabase(){
88
this.accounts = new File("UserAccounts.csv");
9+
this.accountList = this.getList();
910
}
10-
public UserDatabase(File accounts){
11-
this.accounts = accounts;
12-
}
13-
@Override
14-
public boolean UserExists(String username, String email) {
15-
User user = null;
16-
=======
17-
List<User> accountList;
1811
public UserDatabase(File accounts){
1912
this.accounts = accounts;
2013
this.accountList = this.getList();
2114
}
2215
@Override
2316
public boolean UserExists(String username, String email) {
24-
/*User user = null;
25-
>>>>>>> 15-userdatabase-and-user
26-
try(FileInputStream fileIn = new FileInputStream(accounts);
27-
ObjectInputStream in = new ObjectInputStream(fileIn)){
28-
do{
29-
try{
30-
user = (User)in.readObject();
31-
}catch(NullPointerException e){
32-
<<<<<<< HEAD
33-
=======
34-
user = null;
35-
>>>>>>> 15-userdatabase-and-user
36-
break;
37-
}
38-
}while(!user.getEmail().equals(email) && !user.getUsername().equals(username));
39-
}catch(IOException e){
40-
e.printStackTrace();
41-
} catch (ClassNotFoundException e) {
42-
throw new RuntimeException(e);
43-
}
44-
<<<<<<< HEAD
45-
return user != null;
46-
=======
47-
return user != null;*/
4817
for(User user: this.accountList){
4918
if(user.getUsername().equals(username) || user.getEmail().equals(email)){
5019
return true;
5120
}
5221
}
5322
return false;
54-
>>>>>>> 15-userdatabase-and-user
5523
}
5624

5725
// Creates a new user with a username and password, and an email address
@@ -63,10 +31,7 @@ public void createUser(String username, String password, String email, String ty
6331
try(FileOutputStream fileOut = new FileOutputStream(accounts)){
6432
try(ObjectOutputStream out = new ObjectOutputStream(fileOut)){
6533
out.writeObject(newUser);
66-
<<<<<<< HEAD
67-
=======
6834
this.accountList.add(newUser);
69-
>>>>>>> 15-userdatabase-and-user
7035
out.close();
7136
fileOut.close();
7237
}catch(Exception e){
@@ -95,12 +60,6 @@ public List<User> getList() {
9560
List<User> users = new ArrayList<>();
9661
try(FileInputStream fileIn = new FileInputStream(accounts);
9762
ObjectInputStream in = new ObjectInputStream(fileIn)){
98-
<<<<<<< HEAD
99-
User user = (User) in.readObject();
100-
while(user != null){
101-
users.add(user);
102-
user = (User)in.readObject();
103-
=======
10463
/*User user = (User) in.readObject();*/
10564
while(true){
10665
try{
@@ -109,7 +68,6 @@ public List<User> getList() {
10968
catch(EOFException e){
11069
break;
11170
}
112-
>>>>>>> 15-userdatabase-and-user
11371
}
11472
}catch(Exception e){
11573
e.printStackTrace();

src/test/java/UserDatabaseTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
import org.junit.jupiter.api.Test;
33

44
import java.io.File;
5-
<<<<<<< HEAD
6-
import java.util.ArrayList;
7-
=======
8-
>>>>>>> 15-userdatabase-and-user
95
import java.util.List;
106

117
public class UserDatabaseTest {
@@ -27,10 +23,7 @@ public void addingMultipleFiles(){
2723
public void rightEmailWrongUser(){
2824
File accounts = new File("TestUserDatabase2.csv");
2925
UserDatabase accountDatabase = new UserDatabase(accounts);
30-
<<<<<<< HEAD
31-
=======
3226
accountDatabase.createUser("MadhavGopakumar", "123", "[email protected]", "Basic");
33-
>>>>>>> 15-userdatabase-and-user
3427
Assertions.assertTrue(accountDatabase.UserExists("MadG", "[email protected]"));
3528
}
3629
@Test

0 commit comments

Comments
 (0)