Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The TODOs are summarized below (by file) to help your team decide how to split t
---

- `Main.java` (tip: look at how other use cases have been added)
-[ ] TODO: add the logout use case to the app
-[X] TODO: add the logout use case to the app

---

Expand All @@ -116,8 +116,8 @@ The TODOs are summarized below (by file) to help your team decide how to split t
---

- `LogoutInteractor.java` (tip: refer to `ChangePasswordInteractor.java` for similar code)
-[ ] TODO: save the DAO and Presenter in the instance variables.
-[ ] TODO: implement the logic of the Logout Use Case
-[X] TODO: save the DAO and Presenter in the instance variables.
-[X] TODO: implement the logic of the Logout Use Case

> Note: there is no input data necessary for this use case.

Expand Down
1 change: 1 addition & 0 deletions src/main/java/app/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static void main(String[] args) {
.addSignupUseCase()
.addLoginUseCase()
.addChangePasswordUseCase()
.addLogoutUseCase()
.build();

application.pack();
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/interface_adapter/logout/LogoutController.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
package interface_adapter.logout;

import use_case.login.LoginInputData;
import use_case.logout.LogoutInputBoundary;
import use_case.logout.LogoutInteractor;
import use_case.logout.LogoutOutputData;

/**
* The controller for the Logout Use Case.
*/
public class LogoutController {

private LogoutInputBoundary logoutUseCaseInteractor;
private final LogoutInputBoundary logoutUseCaseInteractor;

public LogoutController(LogoutInputBoundary logoutUseCaseInteractor) {
// TODO: Save the interactor in the instance variable.
this.logoutUseCaseInteractor = logoutUseCaseInteractor;

}

/**
* Executes the Logout Use Case.
*/
public void execute() {
// TODO: run the use case interactor for the logout use case
logoutUseCaseInteractor.execute();
}
}
12 changes: 8 additions & 4 deletions src/main/java/use_case/logout/LogoutInteractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
* The Logout Interactor.
*/
public class LogoutInteractor implements LogoutInputBoundary {
private LogoutUserDataAccessInterface userDataAccessObject;
private LogoutOutputBoundary logoutPresenter;
private final LogoutUserDataAccessInterface userDataAccessObject;
private final LogoutOutputBoundary logoutPresenter;

public LogoutInteractor(LogoutUserDataAccessInterface userDataAccessInterface,
LogoutOutputBoundary logoutOutputBoundary) {
// TODO: save the DAO and Presenter in the instance variables.
this.userDataAccessObject = userDataAccessInterface;
this.logoutPresenter = logoutOutputBoundary;
}

@Override
public void execute() {
// TODO: implement the logic of the Logout Use Case
// * set the current username to null in the DAO
// * instantiate the `LogoutOutputData`, which needs to contain the username.
// * tell the presenter to prepare a success view.
final String username = userDataAccessObject.getCurrentUsername();
userDataAccessObject.setCurrentUsername(null);
final LogoutOutputData logoutOutputData = new LogoutOutputData(username);
logoutPresenter.prepareSuccessView(logoutOutputData);
}
}