From 23110a052b510850982f990d01f87c546de0d0ec Mon Sep 17 00:00:00 2001 From: AdrianBalunan Date: Thu, 5 Mar 2026 13:06:46 +0100 Subject: [PATCH] Fix: Hotfixes and better Anonymous handling --- .../sytemutvikling/team6/models/Charity.java | 173 +++++++++--------- .../team6/models/CharityRegistry.java | 48 +++-- .../team6/service/AuthenticationService.java | 1 + .../team6/service/CharityService.java | 4 +- 4 files changed, 110 insertions(+), 116 deletions(-) diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Charity.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Charity.java index 84fb639..2c2cb3f 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Charity.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Charity.java @@ -1,98 +1,95 @@ /** - * This class represents a charity organization. It contains information about the charity such as its name, description, total donations, verification status, and category. - * + * This class represents a charity organization. It contains information about the charity such as + * its name, description, total donations, verification status, and category. + * * @author Adrian Balunan */ package ntnu.sytemutvikling.team6.models; +import java.util.ArrayList; import java.util.List; import java.util.UUID; -import java.util.ArrayList; public class Charity { - /* UUID for uniquely identifying each charity */ - private UUID id; - - /* Name of the charity */ - private String name; - - /* Description of the charity's mission and activities */ - private String description; - - /* Total Donations received */ - private int totalDonations; - - /* Is the charity verified? */ - private boolean isVerified; - - /* Category for the charity */ - private String category; - - /* List that contains the charity's Feedbacks */ - private List feedbacks; - - /** - * Konstructor for creating a new charity. - * The ID is generated automatically using UUID. - * Total donations are initialized to 0. - * The charity is unverified by default. - * - * @param name - * @param description - * @param category - */ - public Charity(String name, String description, String category) { - this.id = UUID.randomUUID(); - this.name = name; - this.description = description; - this.totalDonations = 0; - this.isVerified = false; - this.feedbacks = new ArrayList<>(); - this.category = category; - } - - /** - * Getters for the charity's attributes. - */ - public UUID getId() { - return id; - } - public String getCategory() { - return category; - } - public String getName() { - return name; - } - public String getDescription() { - return description; - } - public int getTotalDonations() { - return totalDonations; - } - public boolean isVerified() { - return isVerified; - } - - /** - * Setter for verification status. - * This one sets the charity as verified. - */ - public void setVerified() { - this.isVerified = true; - } - - /** - * Setter for verification status. - * This one sets the charity as unverified. - */ - public void setUnverified() { - this.isVerified = false; - } - - /** - * Setter for total donations. This method is used to update the total donations when a new donation is made. - */ - public void setTotalDonations(int amount) { - this.totalDonations += amount; - } + /* UUID for uniquely identifying each charity */ + private UUID id; + + /* Name of the charity */ + private String name; + + /* Description of the charity's mission and activities */ + private String description; + + /* Total Donations received */ + private int totalDonations; + + /* Is the charity verified? */ + private boolean isVerified; + + /* Category for the charity */ + private String category; + + /* List that contains the charity's Feedbacks */ + private List feedbacks; + + /** + * Konstructor for creating a new charity. The ID is generated automatically using UUID. Total + * donations are initialized to 0. The charity is unverified by default. + * + * @param name + * @param description + * @param category + */ + public Charity(String name, String description, String category) { + this.id = UUID.randomUUID(); + this.name = name; + this.description = description; + this.totalDonations = 0; + this.isVerified = false; + this.feedbacks = new ArrayList<>(); + this.category = category; + } + + /** Getters for the charity's attributes. */ + public UUID getId() { + return id; + } + + public String getCategory() { + return category; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public int getTotalDonations() { + return totalDonations; + } + + public boolean isVerified() { + return isVerified; + } + + /** Setter for verification status. This one sets the charity as verified. */ + public void setVerified() { + this.isVerified = true; + } + + /** Setter for verification status. This one sets the charity as unverified. */ + public void setUnverified() { + this.isVerified = false; + } + + /** + * Setter for total donations. This method is used to update the total donations when a new + * donation is made. + */ + public void setTotalDonations(int amount) { + this.totalDonations += amount; + } } diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/CharityRegistry.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/CharityRegistry.java index a8d698e..2935c74 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/CharityRegistry.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/CharityRegistry.java @@ -2,37 +2,35 @@ import java.util.*; -public class CharityRegistry{ - private final List charities; +public class CharityRegistry { + private final List charities; - public CharityRegistry(){ - this.charities = new ArrayList<>(); - } + public CharityRegistry() { + this.charities = new ArrayList<>(); + } - public List getAllCharities(){ - return Collections.unmodifiableList(charities); - } + public List getAllCharities() { + return Collections.unmodifiableList(charities); + } - public Optional findCharityById(UUID charityId){ - if(charityId == null){ - throw new IllegalArgumentException("CharityId can not be null."); - } - return charities.stream() - .filter(charity -> charityId.equals(charity.getId())) - .findFirst(); + public Optional findCharityById(UUID charityId) { + if (charityId == null) { + throw new IllegalArgumentException("CharityId can not be null."); } + return charities.stream().filter(charity -> charityId.equals(charity.getId())).findFirst(); + } - public void addCharity(Charity charity){ - if(charity == null){ - throw new IllegalArgumentException("Charity can not be null."); + public void addCharity(Charity charity) { + if (charity == null) { + throw new IllegalArgumentException("Charity can not be null."); } charities.add(charity); - } + } - public boolean removeCharity(UUID charityId){ - if(charityId == null){ - throw new IllegalArgumentException("CharityId can not be null."); - } - return charities.removeIf(charity -> charityId.equals(charity.getId())); + public boolean removeCharity(UUID charityId) { + if (charityId == null) { + throw new IllegalArgumentException("CharityId can not be null."); } -} \ No newline at end of file + return charities.removeIf(charity -> charityId.equals(charity.getId())); + } +} diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/AuthenticationService.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/AuthenticationService.java index e69de29..8b13789 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/AuthenticationService.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/AuthenticationService.java @@ -0,0 +1 @@ + diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/CharityService.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/CharityService.java index 62fe87c..3b66851 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/CharityService.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/CharityService.java @@ -1,5 +1,3 @@ package ntnu.sytemutvikling.team6.service; -public class CharityService { - -} +public class CharityService {}