Skip to content

Project setup #29

Merged
merged 14 commits into from
Mar 3, 2026
10 changes: 10 additions & 0 deletions helpmehelpapplication/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions helpmehelpapplication/.idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions helpmehelpapplication/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions helpmehelpapplication/.idea/dictionaries/project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions helpmehelpapplication/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions helpmehelpapplication/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions helpmehelpapplication/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Donation(double amount, LocalDateTime date, Charity charity, User donor)


// ASSUMES that this is the way to get the anonymous setting from the user's settings.
if (donor.getSettings().getAnonymous() == false) {
if (donor.getSettings().isAnonymous() == false) {
this.isAnonymous = true;
} else {
this.isAnonymous = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Feedback(User user, String comment) {
this.date = LocalDateTime.now();

// ASSUMES that this is the way to get the anonymous setting from the user's settings.
if (user.getSettings().getAnonymous() == false) {
if (user.getSettings().isAnonymous() == false) {
this.isAnonymous = true;
} else {
this.isAnonymous = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
package ntnu.sytemutvikling.team6.models;

import java.util.*;

// Enhetstester mangler

/**
* Represents a user's inbox that contains messages.
* Provides methods to add, remove and get messages.
*
* @author Robin Strand Prestmo
*/
public class Inbox {

private final List<Message> messages;

/**
* Creates an empty inbox with no messages.
*/
public Inbox() {
this.messages = new ArrayList<>();
}

/**
* Returns an unmodifiable view of the messages in this inbox.
*
* @return an unmodifiable list of messages
*/
public List<Message> getMessages() {
return Collections.unmodifiableList(messages);
}

/**
* Finds a specific message by id.
*
* @param messageId the id of the message to search for
* @return messageId the id of the message to remove
* @throws IllegalArgumentException if messageId is null
*/
public Optional<Message> findMessageById(UUID messageId) {
if (messageId == null) {
throw new IllegalArgumentException("MessageId cannot be null.");
}
return messages.stream().filter(message -> messageId.equals(message.getId())).findFirst();
}

/**
* Add´s message to the messages list.
*
* @param message to be added
* @throws IllegalArgumentException if message is null
*/
public void addMessage(Message message) {
if (message == null) {
throw new IllegalArgumentException("Message cannot be null");
}
messages.add(message);
}

/**
* Removes a message from the inbox list.
*
* @param messageId the id to the message to be removed
* @return true if the message was removed, false if not found
* @throws IllegalArgumentException if messageId is null
*/
public boolean removeMessage(UUID messageId) {
if (messageId == null) {
throw new IllegalArgumentException("MessageId cannot be null");
}
return messages.removeIf(message -> messageId.equals(message.getId()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ntnu.sytemutvikling.team6.models;

/**
* Supported application languages.
*
* @author Robin Strand Prestmo
*/
public enum Language {
ENGLISH
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package ntnu.sytemutvikling.team6.models;

import java.time.LocalDateTime;
import java.util.UUID;

// Enhetstester mangler

/**
* Represents a message.
*
* @author Robin Strand Prestmo
*/
public class Message {
private final UUID id;
private final String title;
private final String from;
private final String content;
private final LocalDateTime timeAndDate;

/**
* Creates a message with a unique identifier.
* The message includes a title, a string who it's from,
* content and the time and date.
*
* @param title the title of the message
* @param from who the message is from
* @param content the content of the message
* @throws IllegalArgumentException if title, from or content is null or blank.
*/
public Message(String title,
String from,
String content) {

if (title == null || title.isBlank()) {
throw new IllegalArgumentException("Title cannot be null or blank.");
}

if (from == null || from.isBlank()) {
throw new IllegalArgumentException("From cannot be null or blank.");
}

if (content == null || content.isBlank()) {
throw new IllegalArgumentException("Content cannot be null or blank.");
}

this.id = UUID.randomUUID();
this.title = title;
this.from = from;
this.content = content;
this.timeAndDate = LocalDateTime.now();
}

public UUID getId() {
return id;
}

public String getTitle() {
return title;
}

public String getFrom() {
return from;
}

public String getContent() {
return content;
}

public LocalDateTime getTimeAndDate() {
return timeAndDate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ntnu.sytemutvikling.team6.models;

/**
* Available users
*
* @author Robin Strand Prestmo
*/
public enum Role {
NORMAL_USER,
CHARITY_USER,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,77 @@
package ntnu.sytemutvikling.team6.models;

// Mangler Enhetstesting

/**
* Represents the settings for a user.
*
* @author Robin Strand Prestmo
*/
public class Settings {

private boolean lightMode;
private Language language;
private boolean anonymous;

/**
* Sets standard settings.
* LightMode enabled, language set to English,
* Anonymous disabled
*/
public Settings() {
this(true, Language.ENGLISH, false);
}
/**
* Creates settings for a user.
*
* @param lightMode choose between light or dark mode
* @param language choose language
* @param anonymous choose if user is anonymous
*
*/
public Settings(boolean lightMode, Language language, boolean anonymous) {
if (language == null) {
throw new IllegalArgumentException("Language cannot be null");
}
this.lightMode = lightMode;
this.language = language;
this.anonymous = anonymous;
}

/**
* Toggles between light and dark mode
*/
public void toggleLightMode() {
lightMode = !lightMode;
}

/**
* Toggles anonymous mode on and off
*/
public void toggleAnonymousMode() {
anonymous = !anonymous;
}

/**
* Change language to the chosen language.
*
* @param newLanguage the language to change to.
*/
public void changeLanguage(Language newLanguage) {
if (newLanguage == null) {
throw new IllegalArgumentException("Language cannot be null");
}
language = newLanguage;
}

public boolean isLightMode() {
return lightMode;
}

public Language getLanguage() {
return language;
}

public boolean isAnonymous() {
return anonymous;
}
}
Loading