Skip to content
Snippets Groups Projects
Commit 5e783d1c authored by Carusotto Vincenzo's avatar Carusotto Vincenzo
Browse files

Added UML Class Diagram & Documentation

parent 15528e17
No related branches found
No related tags found
No related merge requests found
Showing
with 17 additions and 57 deletions
File added
File added
......@@ -112,7 +112,7 @@ public class Database {
}
//method for saving new data to hard disk
public void saveData() {
public void saveData() {
try {
FileWriter file = new FileWriter("src/main/resources/data/" + loggedUser + ".json");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
......@@ -201,7 +201,7 @@ public class Database {
//deletes user specific json file
new File("src/main/resources/data/" + user.getUsername() + ".json").delete();
log.debug("User "+user.getUsername()+" json file deleted from \"src/main/resources/data/\"");
log.info("User "+user.getUsername()+" json file deleted from \"src/main/resources/data/\"");
//deletes entry in users.json
try {
......@@ -269,7 +269,6 @@ public class Database {
//Thread to add Flashcards
private class AddFlashcardRunnable implements Runnable {
iFlashcard flashcard;
AddFlashcardRunnable(iFlashcard flashcard){
......
......@@ -43,15 +43,6 @@ public class DoubleFlashcard implements iFlashcard {
this.answer2 = answer[1];
}
@Override
public boolean isAnswerCorrect(String userInput) {
if(userInput.toLowerCase().contains(answer1.toLowerCase()) && userInput.toLowerCase().contains(answer2.toLowerCase()))
return true;
else
return false;
}
@Override
public String getCategory() {
return category;
......
......@@ -47,14 +47,4 @@ public class Flashcard implements iFlashcard {
public void setAnswer(String[] answer) {
this.answer = answer[0];
}
@Override
public boolean isAnswerCorrect(String userInput) {
if(userInput.toLowerCase().contains(answer.toLowerCase()))
return true;
else
return false;
}
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ package de.hdm_stuttgart.mi.vcmseb.Gui;
import de.hdm_stuttgart.mi.vcmseb.Database;
import de.hdm_stuttgart.mi.vcmseb.Exceptions.InvalidPasswordException;
import de.hdm_stuttgart.mi.vcmseb.GuiHelper.AlertHelper;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
......@@ -36,9 +35,6 @@ public class CategoriesController implements Initializable {
@FXML
Button searchBtn;
@FXML
ComboBox comboBox;
@FXML
Button deleteAccountBtn;
......@@ -53,13 +49,13 @@ public class CategoriesController implements Initializable {
@FXML
protected void handleSearchBtnOption (ActionEvent event) throws IOException {
protected void handleSearchBtnOption () throws IOException {
//switch to search scene
Main.getMain().searchScene();
}
@FXML
protected void handleSaveDataOption (ActionEvent event) {
protected void handleSaveDataOption () {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Do you want to save your flashcards?", ButtonType.YES, ButtonType.NO);
alert.showAndWait();
if(alert.getResult() == ButtonType.YES) {
......@@ -72,7 +68,7 @@ public class CategoriesController implements Initializable {
@FXML
protected void handleChangePasswordOption (ActionEvent event) {
protected void handleChangePasswordOption () {
try {
//switch to change password scene
Main.getMain().changePasswordScene();
......@@ -82,7 +78,7 @@ public class CategoriesController implements Initializable {
}
@FXML
protected void handleDeleteAccountOption (ActionEvent event) {
protected void handleDeleteAccountOption () {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "By deleting this account all related flashcards will be lost. Do you want to proceed?", ButtonType.YES, ButtonType.NO);
alert.showAndWait();
if(alert.getResult() == ButtonType.YES) {
......@@ -97,15 +93,6 @@ public class CategoriesController implements Initializable {
}
}
@FXML
protected void handleChangePasswordBtn(){
try {
Main.getMain().changePasswordScene();
} catch (IOException e){
e.printStackTrace();
}
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
data = Database.getInstance();
......
......@@ -4,7 +4,6 @@ import de.hdm_stuttgart.mi.vcmseb.Database;
import de.hdm_stuttgart.mi.vcmseb.Exceptions.ObjectNotFound;
import de.hdm_stuttgart.mi.vcmseb.FlashcardFactory;
import de.hdm_stuttgart.mi.vcmseb.GuiHelper.AlertHelper;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
......@@ -39,13 +38,13 @@ public class CreateDoubleFlashcardController {
Database database = Database.getInstance();
@FXML
protected void handleGoBackBtn(ActionEvent event) throws IOException {
protected void handleGoBackBtn() throws IOException {
//return to categoriesScene
Main.getMain().createFlashcardScene();
log.info("return to previous scene");
}
@FXML
protected void handleSaveBtn(ActionEvent event) throws IOException {
protected void handleSaveBtn() throws IOException {
Window owner =saveBtn.getScene().getWindow();
......
package de.hdm_stuttgart.mi.vcmseb.Gui;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import org.apache.logging.log4j.LogManager;
......@@ -20,7 +19,7 @@ public class CreateFlashcardController {
private Button doubleFlashcard;
@FXML
protected void handleGoBackBtn(ActionEvent event) throws IOException {
protected void handleGoBackBtn() throws IOException {
//return to categoriesScene
Main.getMain().flashcardCategoriesScene();
log.info("return to previous scene");
......
......@@ -3,7 +3,6 @@ package de.hdm_stuttgart.mi.vcmseb.Gui;
import de.hdm_stuttgart.mi.vcmseb.Database;
import de.hdm_stuttgart.mi.vcmseb.GuiHelper.AlertHelper;
import de.hdm_stuttgart.mi.vcmseb.User;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
......@@ -37,7 +36,8 @@ public class LogInController implements Initializable {
//method to handle form submit when logging in
@FXML
protected void handleLogInButtonAction(ActionEvent event) {
protected void handleLogInButtonAction(
) {
Window owner = logInButton.getScene().getWindow();
......
package de.hdm_stuttgart.mi.vcmseb.Gui;
import de.hdm_stuttgart.mi.vcmseb.Database;
import de.hdm_stuttgart.mi.vcmseb.Exceptions.ObjectNotFound;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
......@@ -9,7 +8,6 @@ import javafx.scene.Scene;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.simple.parser.ParseException;
import java.io.IOException;
......@@ -94,6 +92,7 @@ public class Main extends Application {
stage.setScene((flashcardScene));
stage.show();
}
//switch to create new Flashcard scene
public void createFlashcardScene() throws IOException {
Parent createFlashcardParent = FXMLLoader.load(Main.class.getResource("/fxml/createFlashcard.fxml"));
......
......@@ -2,7 +2,6 @@ package de.hdm_stuttgart.mi.vcmseb.Gui;
import de.hdm_stuttgart.mi.vcmseb.Database;
import de.hdm_stuttgart.mi.vcmseb.Interfaces.iFlashcard;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
......@@ -40,12 +39,12 @@ public class SearchController {
//when button is clicked, switch to previous scene
@FXML
protected void handleGoBackBtn(ActionEvent event) throws IOException {
protected void handleGoBackBtn() throws IOException {
Main.getMain().flashcardCategoriesScene();
}
@FXML
protected void handleStartSearch(ActionEvent event) {
protected void handleStartSearch() {
ArrayList<iFlashcard> flashcards;
flashcards = data.searchFlashcards(searchField.getText());
......
......@@ -2,7 +2,6 @@ package de.hdm_stuttgart.mi.vcmseb.Gui;
import de.hdm_stuttgart.mi.vcmseb.Database;
import de.hdm_stuttgart.mi.vcmseb.GuiHelper.AlertHelper;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
......@@ -43,7 +42,7 @@ public class SignUpController implements Initializable {
//method to handle form submit when signing up
@FXML
protected void handleSignUpButtonAction(ActionEvent event) throws IOException {
protected void handleSignUpButtonAction() throws IOException {
Window owner =signUpButton.getScene().getWindow();
if (obligatoryUsernameField.getText().isEmpty()) {
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Form Error!", "Please enter your username");
......@@ -64,9 +63,9 @@ public class SignUpController implements Initializable {
Main.getMain().flashcardCategoriesScene();
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
public void initialize(URL url, ResourceBundle resourceBundle) {
//binds the ENTER key to the button
signUpButton.setDefaultButton(true);
log.info("Loading wisdomCards");
log.info("Loading wisdomCards");
}
}
......@@ -13,6 +13,4 @@ public interface iFlashcard {
String[] getAnswer();
void setAnswer(String[] answer);
boolean isAnswerCorrect(String userInput);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment