Skip to content

Commit

Permalink
Merge pull request #26 from cathrkri/Develop
Browse files Browse the repository at this point in the history
Developed three classes: Donations (no abstract classes, explained in #19), Feedback and Chairty based on v2 class diagram
  • Loading branch information
apbaluna authored Feb 19, 2026
2 parents 6bb96d8 + d54cb26 commit ba9530e
Show file tree
Hide file tree
Showing 22 changed files with 233 additions and 316 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Adrian
.vscode/
.idea/

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,98 @@
/**
* 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.List;
import java.util.UUID;
import java.util.ArrayList;

abstract 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;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,79 @@
package ntnu.sytemutvikling.team6.models;

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

public class Donation {
/* UUID for uniquely identifying each donation */
private UUID charityId;

/* Ammount of money donated */
private double amount;

/* Date and time of the donation */
private LocalDateTime date;

/* The charity that received the donation */
private Charity charity;

/* The user/donor that made the donation */
private User donor;

/**
* Is the donation made anonymously?
* This can be null if the donation was made anonymously.
*
*/
private boolean isAnonymous;

/**
* Constructor for creating a new donation.
* The charityId is generated automatically using UUID.
* If the donation is made anonymously, the isAnonymous parameter is set to true.
* @param amount
* @param date
* @param charity
* @param donor
*/
public Donation(double amount, LocalDateTime date, Charity charity, User donor) {
this.charityId = UUID.randomUUID();
this.amount = amount;
this.date = date;
this.charity = charity;
this.donor = donor;


// ASSUMES that this is the way to get the anonymous setting from the user's settings.
if (donor.getSettings().getAnonymous() == false) {
this.isAnonymous = true;
} else {
this.isAnonymous = false;

}
}

/* Getters for the donation's attributes */
public boolean isAnonymous() {
return isAnonymous;
}

public UUID getCharityId() {
return charityId;
}

public double getAmount() {
return amount;
}

public LocalDateTime getDate() {
return date;
}

public Charity getCharity() {
return charity;
}

public User getDonor() {
return donor;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,65 @@
package ntnu.sytemutvikling.team6.models;

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

public class Feedback {
/* Feedback id */
private UUID feedbackId;

/**
* The author of the feedback
* If annonymous the presentation of the user will be "Anonymous".
*/
private User user;

/* The details of the feedback*/
private String comment;

/* The date and time when the feedback was given */
private LocalDateTime date;

/* Is the feedback given anonymously? */
private boolean isAnonymous;

/**
* Constructor for creating a new feedback.
*
* @param user The user who gives the feedback.
* @param comment The content of the feedback.
*/
public Feedback(User user, String comment) {
this.feedbackId = UUID.randomUUID();
this.user = user;
this.comment = 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) {
this.isAnonymous = true;
} else {
this.isAnonymous = false;
}
}

/**
* Getters for the feedback's attributes.
*
* @return The feedback's attributes.
*/
public UUID getFeedbackId() {
return feedbackId;
}
public String getComment() {
return comment;
}
public LocalDateTime getDate() {
return date;
}
public User getUser() {
return user;
}
public boolean isAnonymous() {
return isAnonymous;
}
}

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit ba9530e

Please sign in to comment.