Skip to content

Commit

Permalink
Fix: Hotfixes and better Anonymous handling
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Mar 5, 2026
1 parent afa366b commit 23110a0
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 116 deletions.
Original file line number Diff line number Diff line change
@@ -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<Feedback> 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<Feedback> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@

import java.util.*;

public class CharityRegistry{
private final List<Charity> charities;
public class CharityRegistry {
private final List<Charity> charities;

public CharityRegistry(){
this.charities = new ArrayList<>();
}
public CharityRegistry() {
this.charities = new ArrayList<>();
}

public List<Charity> getAllCharities(){
return Collections.unmodifiableList(charities);
}
public List<Charity> getAllCharities() {
return Collections.unmodifiableList(charities);
}

public Optional<Charity> 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<Charity> 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.");
}
}
return charities.removeIf(charity -> charityId.equals(charity.getId()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package ntnu.sytemutvikling.team6.service;

public class CharityService {

}
public class CharityService {}

0 comments on commit 23110a0

Please sign in to comment.