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
Binary file added ClassDiagramEx2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 23 additions & 7 deletions src/main/java/com/booleanuk/core/TodoItem.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
package com.booleanuk.core;

public class TodoItem {
public String title;
public String detail;
public String status;
private String title;
private String detail;
private boolean status;

public TodoItem(String title, String detail, String status) {
public TodoItem(String title, String detail) {
this.title = title;
this.detail = detail;
this.status = status;
this.status = false;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getDetail() {
return detail;
}

public void setDetail(String detail) {
this.detail = detail;
}

public void setStatus(String status) {
public void setStatus(boolean status) {
this.status = status;
}

public String getStatus() {
public boolean getStatus() {
return this.status;
}
}
49 changes: 49 additions & 0 deletions src/main/java/com/booleanuk/core/UserAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.booleanuk.core;

public class UserAccount {
private String email;
private String password;
private boolean status;

public UserAccount(String email, String password) {
this.email = email;
this.password = password;
this.status = false;
}

public String getEmail() {
return this.email;
}

public boolean setEmail(String email) {
if (email.contains("@")) {
this.email = email;
return true;
}
System.out.println("Invalid email format");
return false;
}

public String getPassword() {
return this.password;
}

public boolean setPassword(String password) {
if (password.length()>=8) {
this.password = password;
return true;
}
System.out.println("Password should be at least 8 characters");
return false;

}

public boolean getStatus() {
System.out.println(this.status ? "Your account is active. You can now log in." : "Your account hasn't been activated yet");
return this.status;
}

public void setStatus(boolean status) {
this.status = status;
}
}
24 changes: 24 additions & 0 deletions src/test/java/com/booleanuk/core/TodoItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,29 @@
import org.junit.jupiter.api.Test;

class TodoItemTest {
@Test
public void testTitle(){
TodoItem todoItem = new TodoItem("Feed the cat", "Feed Tommy in the evening.");
Assertions.assertEquals("Feed the cat", todoItem.getTitle());
todoItem.setTitle("Feed Tommy");
Assertions.assertEquals("Feed Tommy", todoItem.getTitle());
}


@Test
public void testDetails(){
TodoItem todoItem = new TodoItem("Feed the cat", "Feed Tommy in the evening.");
Assertions.assertEquals("Feed Tommy in the evening.", todoItem.getDetail());
todoItem.setDetail("Feed Tommy in the morning");
Assertions.assertEquals("Feed Tommy in the morning", todoItem.getDetail());
}

@Test
public void testStatus(){
TodoItem todoItem = new TodoItem("Feed the cat", "Feed Tommy in the evening.");
Assertions.assertFalse( todoItem.getStatus());
todoItem.setStatus(true);
Assertions.assertTrue( todoItem.getStatus());
}

}
40 changes: 40 additions & 0 deletions src/test/java/com/booleanuk/core/UserAccountTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.booleanuk.core;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class UserAccountTest {

@Test
void testEmail() {
UserAccount userAccount = new UserAccount("vera@abv.bg", "12345678");
Assertions.assertEquals("vera@abv.bg", userAccount.getEmail());
Assertions.assertTrue(userAccount.setEmail("vera2@abv.bg"));
Assertions.assertEquals("vera2@abv.bg", userAccount.getEmail());
Assertions.assertFalse(userAccount.setEmail("vera.abv.bg"));
Assertions.assertEquals("vera2@abv.bg", userAccount.getEmail());
}


@Test
void testPassword() {
UserAccount userAccount = new UserAccount("vera@abv.bg", "12345678");
Assertions.assertEquals("12345678", userAccount.getPassword());
Assertions.assertTrue(userAccount.setPassword("123456789"));
Assertions.assertEquals("123456789", userAccount.getPassword());
Assertions.assertFalse(userAccount.setPassword("1234567"));
Assertions.assertEquals("123456789", userAccount.getPassword());
}


@Test
void testStatus() {
UserAccount userAccount = new UserAccount("vera@abv.bg", "12345678");
Assertions.assertFalse(userAccount.getStatus());
userAccount.setStatus(true);
Assertions.assertTrue(userAccount.getStatus());
}

}