-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: ci | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: "25" | ||
| cache: maven | ||
|
|
||
| - run: mvn -B test |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| { | ||
| "java.configuration.updateBuildConfiguration": "interactive" | ||
| "java.configuration.updateBuildConfiguration": "interactive", | ||
| "java.compile.nullAnalysis.mode": "disabled" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: ci | ||
|
|
||
| on: | ||
| push: | ||
| branches: main | ||
| pull_request: | ||
| branches: main | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-java@v4 | ||
| with: | ||
| distribition: temurin | ||
| java-version: "25" | ||
| cache: maven | ||
| - run: | ||
| mvn -B test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .idea/ | ||
| target/ |
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.
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.
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <module version="4"> | ||
| <component name="CheckStyle-IDEA-Module" serialisationVersion="2"> | ||
| <option name="activeLocationsIds" /> | ||
| </component> | ||
| </module> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package ntnu.sytemutvikling.team6; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
| System.out.println("Hello world!"); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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. | ||
| * | ||
| * @author Adrian Balunan | ||
| */ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| 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; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| public class CharityRegistry { | ||
| private final List<Charity> charities; | ||
|
|
||
| public CharityRegistry() { | ||
| this.charities = new ArrayList<>(); | ||
| } | ||
|
|
||
| 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 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())); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
| import ntnu.sytemutvikling.team6.models.user.User; | ||
|
|
||
| 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; | ||
| this.isAnonymous = donor.getSettings().isAnonymous(); | ||
| } | ||
|
|
||
| /* 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; | ||
| } | ||
| } |