Skip to content

Commit

Permalink
Fix/Feat: Charity class looks very similar to APICharityData, will ke…
Browse files Browse the repository at this point in the history
…ep APICharityData though.
  • Loading branch information
AdrianBalunan committed Mar 11, 2026
1 parent 3f55f66 commit f4fc2ba
Showing 1 changed file with 52 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class Charity {
/* UUID for uniquely identifying each charity */
private UUID id;
private String org_number;

/* 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;
private String status;

private boolean is_pre_approved;

/* Category for the charity */
private String category;
Expand All @@ -33,26 +31,61 @@ public class Charity {
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.
* Contructor for creating a new charity. The charity is unverified by default.
*
* @param name
* @param description
* @param category
* @param org_number matches from innsamlingkontrollen
* @param name matches from innsamlingkontrollen
* @param is_pre_approved name matches from innsamlingkontrollen
* @param status name matches from innsamlingkontrollen
* @param description no coreleation to innsamlingskontrollen
* @param category no coreleation to innsamlingskontrollen
*
*/
public Charity(String name, String description, String category) {
this.id = UUID.randomUUID();
public Charity(String org_number, String name, String description, String category, boolean is_pre_approved, String status) {
this.org_number = org_number.replaceAll("\\s", "");
this.name = name;
this.description = description;
this.totalDonations = 0;
this.isVerified = false;
this.is_pre_approved = is_pre_approved;
this.status = status;
this.feedbacks = new ArrayList<>();
this.category = category;
}

/**
* Contructor for creating a new charity. Taylored to match data given from Api.
* Other attributes will just be initialized as empty
*
* @param org_number matches from innsamlingkontrollen
* @param name matches from innsamlingkontrollen
* @param is_pre_approved name matches from innsamlingkontrollen
* @param status name matches from innsamlingkontrollen
*
*/
public Charity(String org_number, String name, String category, boolean is_pre_approved, String status) {
this.org_number = org_number.replaceAll("\\s", "");
this.name = name;
this.description = "";
this.is_pre_approved = is_pre_approved;
this.status = status;
this.feedbacks = new ArrayList<>();
this.category = "";
}

/** Getters for the charity's attributes. */
public UUID getId() {
return id;
public String getOrg_number() {
return org_number;
}

public String getStatus() {
return status;
}

public boolean getPreApproved(){return is_pre_approved;}

public List<Feedback> getFeedbacks() {
return feedbacks;
}

public String getCategory() {
Expand All @@ -67,29 +100,14 @@ 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;
this.status = "Approved";
}

/** Setter for verification status. This one sets the charity as unverified. */
public void setUnverified() {
this.isVerified = false;
this.status = "Veto";
}

/**
* 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;
}
}

0 comments on commit f4fc2ba

Please sign in to comment.