Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2021S1#43 from manuelmanuntag96/manue…
Browse files Browse the repository at this point in the history
…l-Feature1

Manuel feature1
  • Loading branch information
yeapcl authored Oct 13, 2020
2 parents 510a59b + d8ca128 commit 4a94674
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void run() {

if (c.isLogIn() == true) {
nowUser = c.getCurrentUser();
//System.out.println(nowUser.getName() + users.getTotalUserCount());
}
//System.out.println(nowUser.getName());
isExit = c.isExit();
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/seedu/duke/command/LogInCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@ public LogInCommand(String input) {

@Override
public void execute(UserList users, Ui ui, User nowUser/*, Storage storage*/) throws DukeException {
boolean doesExist = false;

String[] parsedInputs = input.split(" /", 2);
User newUser = new User(parsedInputs[0], parsedInputs[1]);
currentUser = newUser;
users.addUser(newUser);
ui.greetUser(newUser);
for (int i = 1; i < users.getTotalUserCount(); i++) {
if (parsedInputs[0].equals((users.getUser(i)).getName())) {
if (parsedInputs[1].equals((users.getUser(i)).getPassWord())) {
currentUser = users.getUser(i);
//System.out.println(parsedInputs[0] + " == " + (users.getUser(i)).getName());
doesExist = true;
} else {
throw new DukeException("Wrong Password");
}
}
}

if (doesExist == false) {
//System.out.println("User: " + parsedInputs[0] + " does not exist!");
User newUser = new User(parsedInputs[0], parsedInputs[1]);
currentUser = newUser;
users.addUser(newUser);
}
ui.greetUser(currentUser);
isLogIn = true;


Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/duke/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public String getName() {
return name;
}

public String getPassWord() {
return passWord;
}

public Timetable getTimetable() {
return timetable;
}
Expand Down

0 comments on commit 4a94674

Please sign in to comment.