-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Adrian | ||
| .vscode/ | ||
| .idea/ | ||
| .target/ | ||
| .target/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| 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())); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/DonationRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,39 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| public class DonationRegistry { | ||
| private final List<Donation> donations; | ||
|
|
||
| public DonationRegistry(){ | ||
| this.donations = new ArrayList<>(); | ||
| } | ||
|
|
||
| public List<Donation> getAllDonations(){ | ||
| return Collections.unmodifiableList(donations); | ||
| } | ||
|
|
||
| public Optional<Donation> findDonationById(UUID donationId){ | ||
| if(donationId == null){ | ||
| throw new IllegalArgumentException("DonationId can not be null."); | ||
| } | ||
| return donations.stream() | ||
| .filter(donations -> donationId.equals(donations.getId())) | ||
| .findFirst(); | ||
| } | ||
|
|
||
| public void addDonation(Donation donation){ | ||
| if(donation == null){ | ||
| throw new IllegalArgumentException("Donation can not be null."); | ||
| } | ||
| donations.add(donation); | ||
| } | ||
|
|
||
| public boolean removeDonation(UUID donationId){ | ||
| if(donationId == null){ | ||
| throw new IllegalArgumentException("DonationId can not be null."); | ||
| } | ||
| return donations.removeIf(donation -> donationId.equals(donation.getId)); | ||
| } | ||
|
|
||
| } |