YZY 4 months ago
parent f4cdcf4894
commit 4d04b75c85

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -145,6 +145,7 @@
<workItem from="1744187732630" duration="3771000" />
<workItem from="1744197535410" duration="1873000" />
<workItem from="1744199899989" duration="1551000" />
<workItem from="1744202106298" duration="2978000" />
</task>
<servers />
</component>

@ -0,0 +1,395 @@
package self.cases.teams.teaa;
import java.util.*;
import java.util.stream.Collectors;
public class BankSystem {
private Map<String, Account> accounts;
private List<Transaction> transactions;
public BankSystem() {
accounts = new HashMap<>();
transactions = new ArrayList<>();
}
// Inner class to represent an Account
public static class Account {
private String accountNumber;
private String owner;
private double balance;
public Account(String accountNumber, String owner, double initialBalance) {
this.accountNumber = accountNumber;
this.owner = owner;
this.balance = initialBalance;
}
public String getAccountNumber() {
return accountNumber;
}
public String getOwner() {
return owner;
}
public double getBalance() {
return balance;
}
public void deposit(double amount) {
if (amount > 0) {
balance += amount;
} else {
throw new IllegalArgumentException("Deposit amount must be positive");
}
}
public void withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
} else {
throw new IllegalArgumentException("Invalid withdrawal amount");
}
}
public void transfer(Account target, double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
target.deposit(amount);
System.out.println("Transfer of $" + amount + " from " + accountNumber + " to " + target.getAccountNumber() + " successful.");
} else {
throw new IllegalArgumentException("Invalid transfer amount");
}
}
}
// Inner class to represent a Transaction
public static class Transaction {
private String transactionId;
private String fromAccount;
private String toAccount;
private double amount;
private Date timestamp;
public Transaction(String transactionId, String fromAccount, String toAccount, double amount, Date timestamp) {
this.transactionId = transactionId;
this.fromAccount = fromAccount;
this.toAccount = toAccount;
this.amount = amount;
this.timestamp = timestamp;
}
public String getTransactionId() {
return transactionId;
}
public String getFromAccount() {
return fromAccount;
}
public String getToAccount() {
return toAccount;
}
public double getAmount() {
return amount;
}
public Date getTimestamp() {
return timestamp;
}
}
// Method to create a new account
public String createAccount(String owner, double initialBalance) {
String accountNumber = generateAccountNumber();
Account account = new Account(accountNumber, owner, initialBalance);
accounts.put(accountNumber, account);
return accountNumber;
}
// Method to generate a unique account number
private String generateAccountNumber() {
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 10; i++) {
sb.append(random.nextInt(10));
}
return sb.toString();
}
// Method to deposit money into an account
public void deposit(String accountNumber, double amount) {
Account account = accounts.get(accountNumber);
if (account == null) {
throw new IllegalArgumentException("Account not found");
}
account.deposit(amount);
transactions.add(new Transaction(UUID.randomUUID().toString(), accountNumber, accountNumber, amount, new Date()));
}
// Method to withdraw money from an account
public void withdraw(String accountNumber, double amount) {
Account account = accounts.get(accountNumber);
if (account == null) {
throw new IllegalArgumentException("Account not found");
}
account.withdraw(amount);
transactions.add(new Transaction(UUID.randomUUID().toString(), accountNumber, accountNumber, -amount, new Date()));
}
// Method to transfer money between accounts
public void transfer(String fromAccountNumber, String toAccountNumber, double amount) {
Account fromAccount = accounts.get(fromAccountNumber);
Account toAccount = accounts.get(toAccountNumber);
if (fromAccount == null || toAccount == null) {
throw new IllegalArgumentException("One or both accounts not found");
}
fromAccount.transfer(toAccount, amount);
transactions.add(new Transaction(UUID.randomUUID().toString(), fromAccountNumber, toAccountNumber, amount, new Date()));
}
// Method to list all accounts
public List<Account> listAllAccounts() {
return new ArrayList<>(accounts.values());
}
// Method to list all transactions
public List<Transaction> listAllTransactions() {
return new ArrayList<>(transactions);
}
// Method to find an account by account number
public Account findAccountByNumber(String accountNumber) {
return accounts.get(accountNumber);
}
// Method to calculate total balance of all accounts
public double calculateTotalBalance() {
double totalBalance = 0;
for (Account account : accounts.values()) {
totalBalance += account.getBalance();
}
return totalBalance;
}
// Method to calculate average account balance
public double calculateAverageBalance() {
if (accounts.isEmpty()) {
return 0;
}
double totalBalance = 0;
for (Account account : accounts.values()) {
totalBalance += account.getBalance();
}
return totalBalance / accounts.size();
}
// Method to list top accounts by balance
public List<Account> listTopAccountsByBalance(int topN) {
return accounts.values()
.stream()
.sorted((a1, a2) -> Double.compare(a2.getBalance(), a1.getBalance()))
.limit(topN)
.collect(Collectors.toList());
}
// Method to list most active accounts
public List<Account> listMostActiveAccounts(int topN) {
Map<Account, Integer> activityMap = new HashMap<>();
for (Transaction transaction : transactions) {
Account account = accounts.get(transaction.getFromAccount());
if (account != null) {
activityMap.put(account, activityMap.getOrDefault(account, 0) + 1);
}
account = accounts.get(transaction.getToAccount());
if (account != null) {
activityMap.put(account, activityMap.getOrDefault(account, 0) + 1);
}
}
return activityMap.entrySet()
.stream()
.sorted(Map.Entry.<Account, Integer>comparingByValue().reversed())
.limit(topN)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
}
// Method to list recent transactions
public List<Transaction> listRecentTransactions(int limit) {
return transactions.stream()
.sorted((t1, t2) -> t2.getTimestamp().compareTo(t1.getTimestamp()))
.limit(limit)
.collect(Collectors.toList());
}
// Method to list transactions by account
public List<Transaction> listTransactionsByAccount(String accountNumber) {
return transactions.stream()
.filter(t -> t.getFromAccount().equals(accountNumber) || t.getToAccount().equals(accountNumber))
.collect(Collectors.toList());
}
// Method to calculate total deposits
public double calculateTotalDeposits() {
double totalDeposits = 0;
for (Transaction transaction : transactions) {
if (transaction.getAmount() > 0) {
totalDeposits += transaction.getAmount();
}
}
return totalDeposits;
}
// Method to calculate total withdrawals
public double calculateTotalWithdrawals() {
double totalWithdrawals = 0;
for (Transaction transaction : transactions) {
if (transaction.getAmount() < 0) {
totalWithdrawals -= transaction.getAmount();
}
}
return totalWithdrawals;
}
// Method to calculate total transfers
public double calculateTotalTransfers() {
double totalTransfers = 0;
for (Transaction transaction : transactions) {
if (transaction.getAmount() > 0) {
totalTransfers += transaction.getAmount();
}
}
return totalTransfers;
}
// Method to list all owners
public Set<String> listAllOwners() {
return accounts.values().stream()
.map(Account::getOwner)
.collect(Collectors.toSet());
}
// Method to list accounts by owner
public List<Account> listAccountsByOwner(String owner) {
return accounts.values().stream()
.filter(a -> a.getOwner().equals(owner))
.collect(Collectors.toList());
}
// Method to list accounts with low balance
public List<Account> listAccountsWithLowBalance(double threshold) {
return accounts.values().stream()
.filter(a -> a.getBalance() < threshold)
.collect(Collectors.toList());
}
// Method to list accounts with high balance
public List<Account> listAccountsWithHighBalance(double threshold) {
return accounts.values().stream()
.filter(a -> a.getBalance() >= threshold)
.collect(Collectors.toList());
}
// Main method to demonstrate functionality
public static void main(String[] args) {
BankSystem bank = new BankSystem();
// Creating accounts
String account1 = bank.createAccount("Alice Smith", 1000);
String account2 = bank.createAccount("Bob Johnson", 500);
String account3 = bank.createAccount("Charlie Brown", 2000);
// Depositing money
bank.deposit(account1, 500);
bank.deposit(account2, 200);
// Withdrawing money
bank.withdraw(account1, 200);
// Transferring money
bank.transfer(account1, account2, 300);
// Listing all accounts
System.out.println("\\nList of Accounts:");
for (Account account : bank.listAllAccounts()) {
System.out.println("Account Number: " + account.getAccountNumber() + ", Owner: " + account.getOwner() + ", Balance: $" + account.getBalance());
}
// Listing all transactions
System.out.println("\\nList of Transactions:");
for (Transaction transaction : bank.listAllTransactions()) {
System.out.println("Transaction ID: " + transaction.getTransactionId() + ", From: " + transaction.getFromAccount() + ", To: " + transaction.getToAccount() + ", Amount: $" + transaction.getAmount() + ", Timestamp: " + transaction.getTimestamp());
}
// Finding an account by number
Account account = bank.findAccountByNumber(account1);
if (account != null) {
System.out.println("\\nAccount Found: " + account.getAccountNumber() + ", Owner: " + account.getOwner() + ", Balance: $" + account.getBalance());
}
// Calculating total balance
System.out.println("\\nTotal Balance: $" + bank.calculateTotalBalance());
// Calculating average balance
System.out.println("Average Balance: $" + bank.calculateAverageBalance());
// Listing top accounts by balance
System.out.println("\\nTop Accounts by Balance:");
for (Account topAccount : bank.listTopAccountsByBalance(2)) {
System.out.println(topAccount.getAccountNumber() + ", Owner: " + topAccount.getOwner() + ", Balance: $" + topAccount.getBalance());
}
// Listing most active accounts
System.out.println("\\nMost Active Accounts:");
for (Account activeAccount : bank.listMostActiveAccounts(2)) {
System.out.println(activeAccount.getAccountNumber() + ", Owner: " + activeAccount.getOwner());
}
// Listing recent transactions
System.out.println("\\nRecent Transactions:");
for (Transaction recentTransaction : bank.listRecentTransactions(5)) {
System.out.println(recentTransaction.getTransactionId() + ", From: " + recentTransaction.getFromAccount() + ", To: " + recentTransaction.getToAccount() + ", Amount: $" + recentTransaction.getAmount() + ", Timestamp: " + recentTransaction.getTimestamp());
}
// Listing transactions by account
System.out.println("\\nTransactions by Account " + account1 + ":");
for (Transaction transaction : bank.listTransactionsByAccount(account1)) {
System.out.println(transaction.getTransactionId() + ", From: " + transaction.getFromAccount() + ", To: " + transaction.getToAccount() + ", Amount: $" + transaction.getAmount() + ", Timestamp: " + transaction.getTimestamp());
}
// Calculating total deposits
System.out.println("\\nTotal Deposits: $" + bank.calculateTotalDeposits());
// Calculating total withdrawals
System.out.println("Total Withdrawals: $" + bank.calculateTotalWithdrawals());
// Calculating total transfers
System.out.println("Total Transfers: $" + bank.calculateTotalTransfers());
// Listing all owners
System.out.println("\\nList of Owners:");
for (String owner : bank.listAllOwners()) {
System.out.println(owner);
}
// Listing accounts by owner
System.out.println("\\nAccounts by Owner Alice Smith:");
for (Account accountByOwner : bank.listAccountsByOwner("Alice Smith")) {
System.out.println(accountByOwner.getAccountNumber() + ", Balance: $" + accountByOwner.getBalance());
}
// Listing accounts with low balance
System.out.println("\\nAccounts with Low Balance (<$500):");
for (Account lowBalanceAccount : bank.listAccountsWithLowBalance(500)) {
System.out.println(lowBalanceAccount.getAccountNumber() + ", Owner: " + lowBalanceAccount.getOwner() + ", Balance: $" + lowBalanceAccount.getBalance());
}
// Listing accounts with high balance
System.out.println("\\nAccounts with High Balance (>= $1500):");
for (Account highBalanceAccount : bank.listAccountsWithHighBalance(1500)) {
System.out.println(highBalanceAccount.getAccountNumber() + ", Owner: " + highBalanceAccount.getOwner() + ", Balance: $" + highBalanceAccount.getBalance());
}
}
}

@ -0,0 +1,380 @@
package self.cases.teams.teaa;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.stream.Collectors;
public class BankingSystem {
private static Map<String, Account> accounts;
private Map<String, Loan> loans;
public BankingSystem() {
accounts = new HashMap<>();
loans = new HashMap<>();
}
// Inner class to represent an Account
public static class Account {
private String accountId;
private String ownerName;
private BigDecimal balance;
public Account(String accountId, String ownerName, BigDecimal initialBalance) {
this.accountId = accountId;
this.ownerName = ownerName;
this.balance = initialBalance;
}
public String getAccountId() {
return accountId;
}
public String getOwnerName() {
return ownerName;
}
public BigDecimal getBalance() {
return balance;
}
public void deposit(BigDecimal amount) {
if (amount.compareTo(BigDecimal.ZERO) <= 0) {
throw new IllegalArgumentException("Deposit amount must be positive");
}
balance = balance.add(amount);
}
public void withdraw(BigDecimal amount) {
if (amount.compareTo(BigDecimal.ZERO) <= 0) {
throw new IllegalArgumentException("Withdrawal amount must be positive");
}
if (balance.compareTo(amount) < 0) {
throw new IllegalArgumentException("Insufficient funds");
}
balance = balance.subtract(amount);
}
public void transfer(Account targetAccount, BigDecimal amount) {
if (amount.compareTo(BigDecimal.ZERO) <= 0) {
throw new IllegalArgumentException("Transfer amount must be positive");
}
if (this.balance.compareTo(amount) < 0) {
throw new IllegalArgumentException("Insufficient funds");
}
this.withdraw(amount);
targetAccount.deposit(amount);
}
@Override
public String toString() {
return "Account{" +
"accountId='" + accountId + '\\' +
", ownerName='" + ownerName + '\\' +
", balance=" + balance +
'}';
}
public <TransferRecord> List<TransferRecord> getTransferRecords() {
return null;
}
}
// Inner class to represent a Loan
public static class Loan {
private String loanId;
private String accountId;
private BigDecimal amount;
private BigDecimal interestRate;
private LocalDateTime issueDate;
private LocalDateTime dueDate;
private boolean paid;
public Loan(String loanId, String accountId, BigDecimal amount, BigDecimal interestRate, LocalDateTime issueDate, LocalDateTime dueDate) {
this.loanId = loanId;
this.accountId = accountId;
this.amount = amount;
this.interestRate = interestRate;
this.issueDate = issueDate;
this.dueDate = dueDate;
this.paid = false;
}
public String getLoanId() {
return loanId;
}
public String getAccountId() {
return accountId;
}
public BigDecimal getAmount() {
return amount;
}
public BigDecimal getInterestRate() {
return interestRate;
}
public LocalDateTime getIssueDate() {
return issueDate;
}
public LocalDateTime getDueDate() {
return dueDate;
}
public boolean isPaid() {
return paid;
}
public void payLoan() {
if (paid) {
throw new IllegalStateException("Loan already paid");
}
Account account = accounts.get(accountId);
if (account == null) {
throw new IllegalArgumentException("Account not found");
}
BigDecimal totalAmount = amount.add(amount.multiply(interestRate));
account.withdraw(totalAmount);
paid = true;
}
@Override
public String toString() {
return "Loan{" +
"loanId='" + loanId + '\\' +
", accountId='" + accountId + '\\' +
", amount=" + amount +
", interestRate=" + interestRate +
", issueDate=" + issueDate +
", dueDate=" + dueDate +
", paid=" + paid +
'}';
}
}
// Method to add an account
public void addAccount(String accountId, String ownerName, BigDecimal initialBalance) {
if (accounts.containsKey(accountId)) {
throw new IllegalArgumentException("Account already exists");
}
accounts.put(accountId, new Account(accountId, ownerName, initialBalance));
}
// Method to remove an account
public void removeAccount(String accountId) {
if (!accounts.containsKey(accountId)) {
throw new IllegalArgumentException("Account not found");
}
accounts.remove(accountId);
}
// Method to list all accounts
public List<Account> listAllAccounts() {
return new ArrayList<>(accounts.values());
}
// Method to find an account by ID
public Account findAccountById(String accountId) {
return accounts.get(accountId);
}
// Method to deposit into an account
public void deposit(String accountId, BigDecimal amount) {
Account account = accounts.get(accountId);
if (account == null) {
throw new IllegalArgumentException("Account not found");
}
account.deposit(amount);
}
// Method to withdraw from an account
public void withdraw(String accountId, BigDecimal amount) {
Account account = accounts.get(accountId);
if (account == null) {
throw new IllegalArgumentException("Account not found");
}
account.withdraw(amount);
}
// Method to transfer between accounts
public void transfer(String sourceAccountId, String targetAccountId, BigDecimal amount) {
Account sourceAccount = accounts.get(sourceAccountId);
Account targetAccount = accounts.get(targetAccountId);
if (sourceAccount == null || targetAccount == null) {
throw new IllegalArgumentException("One or both accounts not found");
}
sourceAccount.transfer(targetAccount, amount);
}
// Method to list transfers
public <TransferRecord> List<TransferRecord> listTransfers(String accountId) {
Account account = accounts.get(accountId);
if (account == null) {
throw new IllegalArgumentException("Account not found");
}
return account.getTransferRecords();
}
// Method to add a loan
public void addLoan(String loanId, String accountId, BigDecimal amount, BigDecimal interestRate, LocalDateTime issueDate, LocalDateTime dueDate) {
if (loans.containsKey(loanId)) {
throw new IllegalArgumentException("Loan already exists");
}
loans.put(loanId, new Loan(loanId, accountId, amount, interestRate, issueDate, dueDate));
}
// Method to remove a loan
public void removeLoan(String loanId) {
if (!loans.containsKey(loanId)) {
throw new IllegalArgumentException("Loan not found");
}
loans.remove(loanId);
}
// Method to list all loans
public List<Loan> listAllLoans() {
return new ArrayList<>(loans.values());
}
// Method to find a loan by ID
public Loan findLoanById(String loanId) {
return loans.get(loanId);
}
// Method to pay a loan
public void payLoan(String loanId) {
Loan loan = loans.get(loanId);
if (loan == null) {
throw new IllegalArgumentException("Loan not found");
}
loan.payLoan();
}
// Method to list unpaid loans
public List<Loan> listUnpaidLoans() {
return loans.values().stream()
.filter(l -> !l.isPaid())
.collect(Collectors.toList());
}
// Method to list loans by account
public List<Loan> listLoansByAccount(String accountId) {
return loans.values().stream()
.filter(l -> l.getAccountId().equals(accountId))
.collect(Collectors.toList());
}
// Method to list loans by issue date range
public List<Loan> listLoansByDateRange(LocalDateTime startDate, LocalDateTime endDate) {
return loans.values().stream()
.filter(l -> !l.getIssueDate().isBefore(startDate) && !l.getIssueDate().isAfter(endDate))
.collect(Collectors.toList());
}
// Method to list loans by due date range
public List<Loan> listLoansByDueDateRange(LocalDateTime startDate, LocalDateTime endDate) {
return loans.values().stream()
.filter(l -> !l.getDueDate().isBefore(startDate) && !l.getDueDate().isAfter(endDate))
.collect(Collectors.toList());
}
// Method to list loans by interest rate range
public List<Loan> listLoansByInterestRateRange(BigDecimal minRate, BigDecimal maxRate) {
return loans.values().stream()
.filter(l -> l.getInterestRate().compareTo(minRate) >= 0 && l.getInterestRate().compareTo(maxRate) <= 0)
.collect(Collectors.toList());
}
// Method to list loans by amount range
public List<Loan> listLoansByAmountRange(BigDecimal minAmount, BigDecimal maxAmount) {
return loans.values().stream()
.filter(l -> l.getAmount().compareTo(minAmount) >= 0 && l.getAmount().compareTo(maxAmount) <= 0)
.collect(Collectors.toList());
}
// Main method to demonstrate functionality
public static void main(String[] args) {
BankingSystem bank = new BankingSystem();
// Adding accounts
bank.addAccount("A001", "Alice", new BigDecimal("1000.00"));
bank.addAccount("A002", "Bob", new BigDecimal("500.00"));
// Depositing into accounts
bank.deposit("A001", new BigDecimal("500.00"));
bank.deposit("A002", new BigDecimal("200.00"));
// Withdrawing from accounts
bank.withdraw("A001", new BigDecimal("200.00"));
bank.withdraw("A002", new BigDecimal("100.00"));
// Transferring between accounts
bank.transfer("A001", "A002", new BigDecimal("300.00"));
// Listing all accounts
System.out.println("\\nList of Accounts:");
for (Account account : bank.listAllAccounts()) {
System.out.println(account);
}
// Finding an account by ID
Account aliceAccount = bank.findAccountById("A001");
System.out.println("\\nAlice's Account: " + aliceAccount);
// Adding loans
bank.addLoan("L001", "A001", new BigDecimal("1000.00"), new BigDecimal("0.05"), LocalDateTime.of(2023, 1, 1, 0, 0), LocalDateTime.of(2023, 12, 31, 23, 59));
bank.addLoan("L002", "A002", new BigDecimal("500.00"), new BigDecimal("0.07"), LocalDateTime.of(2023, 2, 1, 0, 0), LocalDateTime.of(2023, 11, 30, 23, 59));
// Paying a loan
bank.payLoan("L001");
// Listing all loans
System.out.println("\\nList of Loans:");
for (Loan loan : bank.listAllLoans()) {
System.out.println(loan);
}
// Finding a loan by ID
Loan loan1 = bank.findLoanById("L001");
System.out.println("\\nLoan L001: " + loan1);
// Listing unpaid loans
System.out.println("\\nUnpaid Loans:");
for (Loan unpaidLoan : bank.listUnpaidLoans()) {
System.out.println(unpaidLoan);
}
// Listing loans by account
System.out.println("\\nLoans by Account A001:");
for (Loan loan : bank.listLoansByAccount("A001")) {
System.out.println(loan);
}
// Listing loans by issue date range
System.out.println("\\nLoans Issued Between 2023-01-01 and 2023-06-30:");
for (Loan loan : bank.listLoansByDateRange(LocalDateTime.of(2023, 1, 1, 0, 0), LocalDateTime.of(2023, 6, 30, 23, 59))) {
System.out.println(loan);
}
// Listing loans by due date range
System.out.println("\\nLoans Due Between 2023-07-01 and 2023-12-31:");
for (Loan loan : bank.listLoansByDueDateRange(LocalDateTime.of(2023, 7, 1, 0, 0), LocalDateTime.of(2023, 12, 31, 23, 59))) {
System.out.println(loan);
}
// Listing loans by interest rate range
System.out.println("\\nLoans with Interest Rate Between 5% and 7%:");
for (Loan loan : bank.listLoansByInterestRateRange(new BigDecimal("0.05"), new BigDecimal("0.07"))) {
System.out.println(loan);
}
// Listing loans by amount range
System.out.println("\\nLoans with Amount Between $500 and $1000:");
for (Loan loan : bank.listLoansByAmountRange(new BigDecimal("500.00"), new BigDecimal("1000.00"))) {
System.out.println(loan);
}
}
}

@ -0,0 +1,154 @@
package self.cases.teams.teaa;
import java.util.ArrayList;
import java.util.List;
public class Bookstore {
private List<Book> books;
public Bookstore() {
books = new ArrayList<>();
}
// Inner class to represent a Book
public static class Book {
private String title;
private String author;
private double price;
private int stock;
public Book(String title, String author, double price, int stock) {
this.title = title;
this.author = author;
this.price = price;
this.stock = stock;
}
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public double getPrice() {
return price;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
}
// Inner class to represent an Order
public static class Order {
private int orderId;
private String customerName;
private Book[] books;
private int[] quantities;
public Order(int orderId, String customerName, Book[] books, int[] quantities) {
this.orderId = orderId;
this.customerName = customerName;
this.books = books;
this.quantities = quantities;
}
public int getOrderId() {
return orderId;
}
public String getCustomerName() {
return customerName;
}
public Book[] getBooks() {
return books;
}
public int[] getQuantities() {
return quantities;
}
public double getTotalPrice() {
double total = 0;
for (int i = 0; i < books.length; i++) {
total += books[i].getPrice() * quantities[i];
}
return total;
}
}
// Method to add a book to the inventory
public void addBook(Book book) {
books.add(book);
}
// Method to find a book by title
public Book findBookByTitle(String title) {
for (Book book : books) {
if (book.getTitle().equals(title)) {
return book;
}
}
return null;
}
// Method to list all books in the inventory
public List<Book> listAllBooks() {
return new ArrayList<>(books);
}
// Method to reduce stock after placing an order
public boolean reduceStock(String title, int quantity) {
Book book = findBookByTitle(title);
if (book != null && book.getStock() >= quantity) {
book.setStock(book.getStock() - quantity);
return true;
}
return false;
}
// Main method to demonstrate functionality
public static void main(String[] args) {
Bookstore bookstore = new Bookstore();
// Adding some books to the inventory
bookstore.addBook(new Bookstore.Book("Effective Java", "Joshua Bloch", 49.99, 50));
bookstore.addBook(new Bookstore.Book("Clean Code", "Robert C. Martin", 39.99, 30));
bookstore.addBook(new Bookstore.Book("The Pragmatic Programmer", "Andrew Hunt", 29.99, 20));
// Listing all books in the inventory
System.out.println("List of Books:");
for (Bookstore.Book book : bookstore.listAllBooks()) {
System.out.println(book.getTitle() + " by " + book.getAuthor());
}
// Placing an order
Bookstore.Book[] books = {bookstore.findBookByTitle("Effective Java"), bookstore.findBookByTitle("Clean Code")};
int[] quantities = {2, 1};
Bookstore.Order order = new Bookstore.Order(1, "John Doe", books, quantities);
System.out.println("\\nOrder Details:");
System.out.println("Customer: " + order.getCustomerName());
System.out.println("Order ID: " + order.getOrderId());
for (int i = 0; i < books.length; i++) {
System.out.println("Book: " + books[i].getTitle() + ", Quantity: " + quantities[i]);
}
System.out.println("Total Price: $" + order.getTotalPrice());
// Reducing stock after placing the order
bookstore.reduceStock("Effective Java", 2);
bookstore.reduceStock("Clean Code", 1);
// Listing all books again to verify stock reduction
System.out.println("\\nUpdated List of Books:");
for (Bookstore.Book book : bookstore.listAllBooks()) {
System.out.println(book.getTitle() + " by " + book.getAuthor() + ", Stock: " + book.getStock());
}
}
}

@ -0,0 +1,578 @@
package self.cases.teams.teaa;
import java.util.*;
import java.time.LocalDate;
import java.util.stream.Collectors;
public class ClubManage {
private Map<Integer, Club> clubs;
private Map<Integer, Member> members;
private Map<Integer, Event> events;
public ClubManage() {
clubs = new HashMap<>();
members = new HashMap<>();
events = new HashMap<>();
}
// Inner class to represent a Club
public static class Club {
private int clubId;
private String name;
private String description;
private LocalDate foundingDate;
private int memberCount;
public Club(int clubId, String name, String description, LocalDate foundingDate) {
this.clubId = clubId;
this.name = name;
this.description = description;
this.foundingDate = foundingDate;
this.memberCount = 0;
}
public int getClubId() {
return clubId;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public LocalDate getFoundingDate() {
return foundingDate;
}
public int getMemberCount() {
return memberCount;
}
public void increaseMemberCount() {
this.memberCount++;
}
public void decreaseMemberCount() {
if (this.memberCount > 0) {
this.memberCount--;
}
}
@Override
public String toString() {
return "Club{" +
"clubId=" + clubId +
", name='" + name + '\\' +
", description='" + description + '\\' +
", foundingDate=" + foundingDate +
", memberCount=" + memberCount +
'}';
}
public void setName(String newName) {
}
public void setDescription(String newDescription) {
}
}
// Inner class to represent a Member
public static class Member {
private int memberId;
private String name;
private String email;
private String role;
private boolean isActive;
public Member(int memberId, String name, String email, String role) {
this.memberId = memberId;
this.name = name;
this.email = email;
this.role = role;
this.isActive = true;
}
public int getMemberId() {
return memberId;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public String getRole() {
return role;
}
public boolean isActive() {
return isActive;
}
public void deactivate() {
this.isActive = false;
}
@Override
public String toString() {
return "Member{" +
"memberId=" + memberId +
", name='" + name + '\\' +
", email='" + email + '\\' +
", role='" + role + '\\' +
", isActive=" + isActive +
'}';
}
public void setName(String newName) {
}
public void setEmail(String newEmail) {
}
public void setRole(String newRole) {
}
public int getClubId() {
return 0;
}
}
// Inner class to represent an Event
public static class Event {
private int eventId;
private int clubId;
private LocalDate eventDate;
private String eventName;
private String description;
public Event(int eventId, int clubId, LocalDate eventDate, String eventName, String description) {
this.eventId = eventId;
this.clubId = clubId;
this.eventDate = eventDate;
this.eventName = eventName;
this.description = description;
}
public int getEventId() {
return eventId;
}
public int getClubId() {
return clubId;
}
public LocalDate getEventDate() {
return eventDate;
}
public String getEventName() {
return eventName;
}
public String getDescription() {
return description;
}
@Override
public String toString() {
return "Event{" +
"eventId=" + eventId +
", clubId=" + clubId +
", eventDate=" + eventDate +
", eventName='" + eventName + '\\' +
", description='" + description + '\\' +
'}';
}
public void setEventDate(LocalDate newEventDate) {
}
public void setEventName(String newEventName) {
}
public void setDescription(String newDescription) {
}
}
// Method to add a club
public void addClub(int clubId, String name, String description, LocalDate foundingDate) {
if (clubs.containsKey(clubId)) {
throw new IllegalArgumentException("Club already exists");
}
clubs.put(clubId, new Club(clubId, name, description, foundingDate));
}
// Method to remove a club
public void removeClub(int clubId) {
if (!clubs.containsKey(clubId)) {
throw new IllegalArgumentException("Club not found");
}
clubs.remove(clubId);
}
// Method to list all clubs
public List<Club> listAllClubs() {
return new ArrayList<>(clubs.values());
}
// Method to find a club by ID
public Club findClubById(int clubId) {
return clubs.get(clubId);
}
// Method to add a member
public void addMember(int memberId, String name, String email, String role) {
if (members.containsKey(memberId)) {
throw new IllegalArgumentException("Member already exists");
}
members.put(memberId, new Member(memberId, name, email, role));
}
// Method to remove a member
public void removeMember(int memberId) {
if (!members.containsKey(memberId)) {
throw new IllegalArgumentException("Member not found");
}
members.remove(memberId);
}
// Method to list all members
public List<Member> listAllMembers() {
return new ArrayList<>(members.values());
}
// Method to find a member by ID
public Member findMemberById(int memberId) {
return members.get(memberId);
}
// Method to deactivate a member
public void deactivateMember(int memberId) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
member.deactivate();
}
// Method to add an event
public void addEvent(int eventId, int clubId, LocalDate eventDate, String eventName, String description) {
if (events.containsKey(eventId)) {
throw new IllegalArgumentException("Event already exists");
}
events.put(eventId, new Event(eventId, clubId, eventDate, eventName, description));
Club club = clubs.get(clubId);
if (club != null) {
club.increaseMemberCount();
}
}
// Method to remove an event
public void removeEvent(int eventId) {
if (!events.containsKey(eventId)) {
throw new IllegalArgumentException("Event not found");
}
Event event = events.get(eventId);
Club club = clubs.get(event.getClubId());
if (club != null) {
club.decreaseMemberCount();
}
events.remove(eventId);
}
// Method to list all events
public List<Event> listAllEvents() {
return new ArrayList<>(events.values());
}
// Method to find an event by ID
public Event findEventById(int eventId) {
return events.get(eventId);
}
// Method to list events by club
public List<Event> listEventsByClub(int clubId) {
return events.values().stream()
.filter(e -> e.getClubId() == clubId)
.collect(Collectors.toList());
}
// Method to list events by date range
public List<Event> listEventsByDateRange(LocalDate startDate, LocalDate endDate) {
return events.values().stream()
.filter(e -> !e.getEventDate().isBefore(startDate) && !e.getEventDate().isAfter(endDate))
.collect(Collectors.toList());
}
// Method to list events by name
public List<Event> listEventsByName(String eventName) {
return events.values().stream()
.filter(e -> e.getEventName().equalsIgnoreCase(eventName))
.collect(Collectors.toList());
}
// Method to list events by description
public List<Event> listEventsByDescription(String description) {
return events.values().stream()
.filter(e -> e.getDescription().contains(description))
.collect(Collectors.toList());
}
// Method to list events by active members
public List<Event> listEventsByActiveMembers() {
return events.values().stream()
.filter(e -> {
Club club = clubs.get(e.getClubId());
return club != null && club.getMemberCount() > 0;
})
.collect(Collectors.toList());
}
// Method to update club information
public void updateClub(int clubId, String newName, String newDescription) {
Club club = clubs.get(clubId);
if (club == null) {
throw new IllegalArgumentException("Club not found");
}
club.setName(newName);
club.setDescription(newDescription);
}
// Method to update member information
public void updateMember(int memberId, String newName, String newEmail, String newRole) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
member.setName(newName);
member.setEmail(newEmail);
member.setRole(newRole);
}
// Method to update event information
public void updateEvent(int eventId, LocalDate newEventDate, String newEventName, String newDescription) {
Event event = events.get(eventId);
if (event == null) {
throw new IllegalArgumentException("Event not found");
}
event.setEventDate(newEventDate);
event.setEventName(newEventName);
event.setDescription(newDescription);
}
// Method to search for clubs by name
public List<Club> searchClubsByName(String name) {
return clubs.values().stream()
.filter(c -> c.getName().toLowerCase().contains(name.toLowerCase()))
.collect(Collectors.toList());
}
// Method to search for members by role
public List<Member> searchMembersByRole(String role) {
return members.values().stream()
.filter(m -> m.getRole().equalsIgnoreCase(role))
.collect(Collectors.toList());
}
// Method to search for events by description
public List<Event> searchEventsByDescription(String description) {
return events.values().stream()
.filter(e -> e.getDescription().toLowerCase().contains(description.toLowerCase()))
.collect(Collectors.toList());
}
// Method to assign a member to a club
public void assignMemberToClub(int memberId, int clubId) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
Club club = clubs.get(clubId);
if (club == null) {
throw new IllegalArgumentException("Club not found");
}
member.setRole("Member"); // Assign default role
club.increaseMemberCount();
}
// Method to unassign a member from a club
public void unassignMemberFromClub(int memberId, int clubId) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
Club club = clubs.get(clubId);
if (club == null) {
throw new IllegalArgumentException("Club not found");
}
member.setRole("Inactive"); // Set inactive role
club.decreaseMemberCount();
}
// Method to list all members assigned to a club
public List<Member> listMembersAssignedToClub(int clubId) {
Club club = clubs.get(clubId);
if (club == null) {
throw new IllegalArgumentException("Club not found");
}
return members.values().stream()
.filter(m -> m.getRole().equalsIgnoreCase("Member") && m.getEmail().endsWith("@club" + clubId + ".com"))
.collect(Collectors.toList());
}
// Method to list all clubs a member is assigned to
public List<Club> listClubsForMember(int memberId) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
return clubs.values().stream()
.filter(c -> c.getMemberCount() > 0 && c.getMemberCount() < 100)
.collect(Collectors.toList());
}
// Method to list all events assigned to a club
public List<Event> listEventsAssignedToClub(int clubId) {
Club club = clubs.get(clubId);
if (club == null) {
throw new IllegalArgumentException("Club not found");
}
return events.values().stream()
.filter(e -> e.getClubId() == clubId)
.collect(Collectors.toList());
}
// Method to list all members attending an event
public List<Member> listMembersAttendingEvent(int eventId) {
Event event = events.get(eventId);
if (event == null) {
throw new IllegalArgumentException("Event not found");
}
return members.values().stream()
.filter(m -> m.getRole().equalsIgnoreCase("Attendee") && m.getEmail().endsWith("@event" + eventId + ".com"))
.collect(Collectors.toList());
}
// Method to assign a member to attend an event
public void assignMemberToAttendEvent(int memberId, int eventId) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
Event event = events.get(eventId);
if (event == null) {
throw new IllegalArgumentException("Event not found");
}
member.setRole("Attendee"); // Assign role as Attendee
member.setEmail(member.getEmail().replace("@club", "@event"));
}
// Method to unassign a member from attending an event
public void unassignMemberFromAttendingEvent(int memberId, int eventId) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
Event event = events.get(eventId);
if (event == null) {
throw new IllegalArgumentException("Event not found");
}
member.setRole("Inactive"); // Set inactive role
member.setEmail(member.getEmail().replace("@event", "@club"));
}
// Method to list all members who are active in any club
public List<Member> listActiveMembersInAnyClub() {
return members.values().stream()
.filter(m -> m.isActive())
.collect(Collectors.toList());
}
// Method to list all events that have been held within the last month
public List<Event> listRecentEvents() {
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
return events.values().stream()
.filter(e -> !e.getEventDate().isBefore(oneMonthAgo))
.collect(Collectors.toList());
}
// Method to list all clubs with more than 10 members
public List<Club> listLargeClubs() {
return clubs.values().stream()
.filter(c -> c.getMemberCount() > 10)
.collect(Collectors.toList());
}
// Method to list all members who are active in clubs with more than 10 members
public List<Member> listActiveMembersInLargeClubs() {
return members.values().stream()
.filter(m -> m.isActive() && clubs.values().stream()
.anyMatch(c -> c.getMemberCount() > 10 && c.getMemberCount() < 100))
.collect(Collectors.toList());
}
// Method to list all events that have been held in clubs with more than 10 members
public List<Event> listEventsInLargeClubs() {
return events.values().stream()
.filter(e -> clubs.values().stream()
.anyMatch(c -> c.getMemberCount() > 10 && c.getMemberCount() < 100 && c.getClubId() == e.getClubId()))
.collect(Collectors.toList());
}
// Method to list all clubs that have hosted events in the last year
public List<Club> listClubsWithRecentEvents() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return clubs.values().stream()
.filter(c -> events.values().stream()
.anyMatch(e -> e.getClubId() == c.getClubId() && !e.getEventDate().isBefore(oneYearAgo)))
.collect(Collectors.toList());
}
// Method to list all members who have attended events in the last year
public List<Member> listMembersWithRecentEventAttendance() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return members.values().stream()
.filter(m -> events.values().stream()
.anyMatch(e -> e.getClubId() == m.getClubId() && !e.getEventDate().isBefore(oneYearAgo)))
.collect(Collectors.toList());
}
// Method to list all events that have been held in clubs with more than 10 members in the last year
public List<Event> listEventsInLargeClubsLastYear() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return events.values().stream()
.filter(e -> clubs.values().stream()
.anyMatch(c -> c.getMemberCount() > 10 && c.getMemberCount() < 100 && c.getClubId() == e.getClubId()
&& !e.getEventDate().isBefore(oneYearAgo)))
.collect(Collectors.toList());
}
// Method to list all clubs that have hosted events in the last year and have more than 10 members
public List<Club> listClubsWithRecentEventsAndLargeMembership() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return clubs.values().stream()
.filter(c -> c.getMemberCount() > 10 && c.getMemberCount() < 100 && events.values().stream()
.anyMatch(e -> e.getClubId() == c.getClubId() && !e.getEventDate().isBefore(oneYearAgo)))
.collect(Collectors.toList());
}
// Method to list all members who have attended events in clubs with more than 10 members in the last year
public List<Member> listMembersWithRecentEventAttendanceInLargeClubs() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return members.values().stream()
.filter(m -> m.isActive() && clubs.values().stream()
.anyMatch(c -> c.getMemberCount() > 10 && c.getMemberCount() < 100 && c.getClubId() == m.getClubId()
&& events.values().stream()
.anyMatch(e -> e.getClubId() == c.getClubId() && !e.getEventDate().isBefore(oneYearAgo)))
).collect(Collectors.toList());
}
}

@ -0,0 +1,392 @@
package self.cases.teams.teaa;
import java.util.*;
import java.time.LocalDate;
import java.util.stream.Collectors;
public class ClubManagementSystem {
private Map<Integer, Club> clubs;
private Map<Integer, Member> members;
private Map<Integer, Event> events;
public ClubManagementSystem() {
clubs = new HashMap<>();
members = new HashMap<>();
events = new HashMap<>();
}
// Inner class to represent a Club
public static class Club {
private int clubId;
private String name;
private String description;
private LocalDate foundingDate;
private int memberCount;
public Club(int clubId, String name, String description, LocalDate foundingDate) {
this.clubId = clubId;
this.name = name;
this.description = description;
this.foundingDate = foundingDate;
this.memberCount = 0;
}
public int getClubId() {
return clubId;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public LocalDate getFoundingDate() {
return foundingDate;
}
public int getMemberCount() {
return memberCount;
}
public void increaseMemberCount() {
this.memberCount++;
}
public void decreaseMemberCount() {
if (this.memberCount > 0) {
this.memberCount--;
}
}
@Override
public String toString() {
return "Club{" +
"clubId=" + clubId +
", name='" + name + '\\' +
", description='" + description + '\\' +
", foundingDate=" + foundingDate +
", memberCount=" + memberCount +
'}';
}
}
// Inner class to represent a Member
public static class Member {
private int memberId;
private String name;
private String email;
private String role;
private boolean isActive;
public Member(int memberId, String name, String email, String role) {
this.memberId = memberId;
this.name = name;
this.email = email;
this.role = role;
this.isActive = true;
}
public int getMemberId() {
return memberId;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public String getRole() {
return role;
}
public boolean isActive() {
return isActive;
}
public void deactivate() {
this.isActive = false;
}
@Override
public String toString() {
return "Member{" +
"memberId=" + memberId +
", name='" + name + '\\' +
", email='" + email + '\\' +
", role='" + role + '\\' +
", isActive=" + isActive +
'}';
}
}
// Inner class to represent an Event
public static class Event {
private int eventId;
private int clubId;
private LocalDate eventDate;
private String eventName;
private String description;
public Event(int eventId, int clubId, LocalDate eventDate, String eventName, String description) {
this.eventId = eventId;
this.clubId = clubId;
this.eventDate = eventDate;
this.eventName = eventName;
this.description = description;
}
public int getEventId() {
return eventId;
}
public int getClubId() {
return clubId;
}
public LocalDate getEventDate() {
return eventDate;
}
public String getEventName() {
return eventName;
}
public String getDescription() {
return description;
}
@Override
public String toString() {
return "Event{" +
"eventId=" + eventId +
", clubId=" + clubId +
", eventDate=" + eventDate +
", eventName='" + eventName + '\\' +
", description='" + description + '\\' +
'}';
}
}
// Method to add a club
public void addClub(int clubId, String name, String description, LocalDate foundingDate) {
if (clubs.containsKey(clubId)) {
throw new IllegalArgumentException("Club already exists");
}
clubs.put(clubId, new Club(clubId, name, description, foundingDate));
}
// Method to remove a club
public void removeClub(int clubId) {
if (!clubs.containsKey(clubId)) {
throw new IllegalArgumentException("Club not found");
}
clubs.remove(clubId);
}
// Method to list all clubs
public List<Club> listAllClubs() {
return new ArrayList<>(clubs.values());
}
// Method to find a club by ID
public Club findClubById(int clubId) {
return clubs.get(clubId);
}
// Method to add a member
public void addMember(int memberId, String name, String email, String role) {
if (members.containsKey(memberId)) {
throw new IllegalArgumentException("Member already exists");
}
members.put(memberId, new Member(memberId, name, email, role));
}
// Method to remove a member
public void removeMember(int memberId) {
if (!members.containsKey(memberId)) {
throw new IllegalArgumentException("Member not found");
}
members.remove(memberId);
}
// Method to list all members
public List<Member> listAllMembers() {
return new ArrayList<>(members.values());
}
// Method to find a member by ID
public Member findMemberById(int memberId) {
return members.get(memberId);
}
// Method to deactivate a member
public void deactivateMember(int memberId) {
Member member = members.get(memberId);
if (member == null) {
throw new IllegalArgumentException("Member not found");
}
member.deactivate();
}
// Method to add an event
public void addEvent(int eventId, int clubId, LocalDate eventDate, String eventName, String description) {
if (events.containsKey(eventId)) {
throw new IllegalArgumentException("Event already exists");
}
events.put(eventId, new Event(eventId, clubId, eventDate, eventName, description));
Club club = clubs.get(clubId);
if (club != null) {
club.increaseMemberCount();
}
}
// Method to remove an event
public void removeEvent(int eventId) {
if (!events.containsKey(eventId)) {
throw new IllegalArgumentException("Event not found");
}
Event event = events.get(eventId);
Club club = clubs.get(event.getClubId());
if (club != null) {
club.decreaseMemberCount();
}
events.remove(eventId);
}
// Method to list all events
public List<Event> listAllEvents() {
return new ArrayList<>(events.values());
}
// Method to find an event by ID
public Event findEventById(int eventId) {
return events.get(eventId);
}
// Method to list events by club
public List<Event> listEventsByClub(int clubId) {
return events.values().stream()
.filter(e -> e.getClubId() == clubId)
.collect(Collectors.toList());
}
// Method to list events by date range
public List<Event> listEventsByDateRange(LocalDate startDate, LocalDate endDate) {
return events.values().stream()
.filter(e -> !e.getEventDate().isBefore(startDate) && !e.getEventDate().isAfter(endDate))
.collect(Collectors.toList());
}
// Method to list events by name
public List<Event> listEventsByName(String eventName) {
return events.values().stream()
.filter(e -> e.getEventName().equalsIgnoreCase(eventName))
.collect(Collectors.toList());
}
// Method to list events by description
public List<Event> listEventsByDescription(String description) {
return events.values().stream()
.filter(e -> e.getDescription().contains(description))
.collect(Collectors.toList());
}
// Method to list events by active members
public List<Event> listEventsByActiveMembers() {
return events.values().stream()
.filter(e -> {
Club club = clubs.get(e.getClubId());
return club != null && club.getMemberCount() > 0;
})
.collect(Collectors.toList());
}
// Main method to demonstrate functionality
public static void main(String[] args) {
ClubManagementSystem system = new ClubManagementSystem();
// Adding clubs
system.addClub(1, "Chess Club", "A club for chess enthusiasts", LocalDate.of(2020, 1, 1));
system.addClub(2, "Book Club", "A club for book lovers", LocalDate.of(2018, 5, 15));
system.addClub(3, "Photography Club", "A club for photography enthusiasts", LocalDate.of(2019, 10, 1));
// Listing all clubs
System.out.println("\\nList of Clubs:");
for (Club club : system.listAllClubs()) {
System.out.println(club);
}
// Finding a club by ID
Club chessClub = system.findClubById(1);
System.out.println("\\nChess Club: " + chessClub);
// Adding members
system.addMember(101, "Alice", "alice@example.com", "President");
system.addMember(102, "Bob", "bob@example.com", "Secretary");
system.addMember(103, "Charlie", "charlie@example.com", "Treasurer");
// Listing all members
System.out.println("\\nList of Members:");
for (Member member : system.listAllMembers()) {
System.out.println(member);
}
// Finding a member by ID
Member alice = system.findMemberById(101);
System.out.println("\\nAlice: " + alice);
// Deactivating a member
system.deactivateMember(101);
// Adding events
system.addEvent(1001, 1, LocalDate.of(2023, 1, 15), "Chess Tournament", "Annual chess tournament");
system.addEvent(1002, 2, LocalDate.of(2023, 2, 20), "Book Discussion", "Monthly book discussion");
system.addEvent(1003, 3, LocalDate.of(2023, 3, 10), "Photo Walk", "Monthly photo walk");
// Listing all events
System.out.println("\\nList of Events:");
for (Event event : system.listAllEvents()) {
System.out.println(event);
}
// Finding an event by ID
Event chessTournament = system.findEventById(1001);
System.out.println("\\nChess Tournament: " + chessTournament);
// Listing events by club
System.out.println("\\nEvents by Chess Club:");
for (Event event : system.listEventsByClub(1)) {
System.out.println(event);
}
// Listing events by date range
System.out.println("\\nEvents between January 1 and March 31, 2023:");
for (Event event : system.listEventsByDateRange(LocalDate.of(2023, 1, 1), LocalDate.of(2023, 3, 31))) {
System.out.println(event);
}
// Listing events by name
System.out.println("\\nEvents named 'Book Discussion':");
for (Event event : system.listEventsByName("Book Discussion")) {
System.out.println(event);
}
// Listing events by description
System.out.println("\\nEvents with description containing 'Annual':");
for (Event event : system.listEventsByDescription("Annual")) {
System.out.println(event);
}
// Listing events by active members
System.out.println("\\nEvents with active members:");
for (Event event : system.listEventsByActiveMembers()) {
System.out.println(event);
}
}
}

@ -0,0 +1,422 @@
package self.cases.teams.teaa;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.stream.Collectors;
public class ECommercePlatform {
private Map<String, Product> products;
private Map<String, Order> orders;
private Map<String, User> users;
public ECommercePlatform() {
products = new HashMap<>();
orders = new HashMap<>();
users = new HashMap<>();
}
// Inner class to represent a Product
public static class Product {
private String productId;
private String name;
private BigDecimal price;
private int stock;
public Product(String productId, String name, BigDecimal price, int stock) {
this.productId = productId;
this.name = name;
this.price = price;
this.stock = stock;
}
public String getProductId() {
return productId;
}
public String getName() {
return name;
}
public BigDecimal getPrice() {
return price;
}
public int getStock() {
return stock;
}
public void updateStock(int quantity) {
if (quantity > 0) {
stock += quantity;
} else {
throw new IllegalArgumentException("Invalid stock update quantity");
}
}
@Override
public String toString() {
return "Product{" +
"productId='" + productId + '\\' +
", name='" + name + '\\' +
", price=" + price +
", stock=" + stock +
'}';
}
}
// Inner class to represent an Order
public static class Order {
private String orderId;
private String userId;
private LocalDateTime orderDate;
private List<OrderItem> items;
public Order(String orderId, String userId, LocalDateTime orderDate, List<OrderItem> items) {
this.orderId = orderId;
this.userId = userId;
this.orderDate = orderDate;
this.items = items;
}
public String getOrderId() {
return orderId;
}
public String getUserId() {
return userId;
}
public LocalDateTime getOrderDate() {
return orderDate;
}
public List<OrderItem> getItems() {
return items;
}
public BigDecimal getTotalPrice() {
BigDecimal total = BigDecimal.ZERO;
for (OrderItem item : items) {
total = total.add(item.getPrice().multiply(BigDecimal.valueOf(item.getQuantity())));
}
return total;
}
@Override
public String toString() {
return "Order{" +
"orderId='" + orderId + '\\' +
", userId='" + userId + '\\' +
", orderDate=" + orderDate +
", items=" + items +
", totalPrice=" + getTotalPrice() +
'}';
}
}
// Inner class to represent an OrderItem
public static class OrderItem {
private String productId;
private int quantity;
private BigDecimal price;
public OrderItem(String productId, int quantity, BigDecimal price) {
this.productId = productId;
this.quantity = quantity;
this.price = price;
}
public String getProductId() {
return productId;
}
public int getQuantity() {
return quantity;
}
public BigDecimal getPrice() {
return price;
}
@Override
public String toString() {
return "OrderItem{" +
"productId='" + productId + '\\' +
", quantity=" + quantity +
", price=" + price +
'}';
}
}
// Inner class to represent a User
public static class User {
private String userId;
private String username;
private String password;
private boolean isAdmin;
public User(String userId, String username, String password, boolean isAdmin) {
this.userId = userId;
this.username = username;
this.password = password;
this.isAdmin = isAdmin;
}
public String getUserId() {
return userId;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public boolean isAdmin() {
return isAdmin;
}
public void setPassword(String newPassword) {
this.password = newPassword;
}
@Override
public String toString() {
return "User{" +
"userId='" + userId + '\\' +
", username='" + username + '\\' +
", password='" + password + '\\' +
", isAdmin=" + isAdmin +
'}';
}
}
// Method to add a product
public void addProduct(String productId, String name, BigDecimal price, int stock) {
if (products.containsKey(productId)) {
throw new IllegalArgumentException("Product already exists");
}
products.put(productId, new Product(productId, name, price, stock));
}
// Method to update product stock
public void updateProductStock(String productId, int quantity) {
Product product = products.get(productId);
if (product == null) {
throw new IllegalArgumentException("Product not found");
}
product.updateStock(quantity);
}
// Method to remove a product
public void removeProduct(String productId) {
if (!products.containsKey(productId)) {
throw new IllegalArgumentException("Product not found");
}
products.remove(productId);
}
// Method to list all products
public List<Product> listAllProducts() {
return new ArrayList<>(products.values());
}
// Method to find a product by ID
public Product findProductById(String productId) {
return products.get(productId);
}
// Method to place an order
public String placeOrder(String userId, List<OrderItem> items) {
if (!users.containsKey(userId)) {
throw new IllegalArgumentException("User not found");
}
User user = users.get(userId);
if (!user.isAdmin()) {
throw new IllegalStateException("Only admin can place orders");
}
String orderId = UUID.randomUUID().toString();
LocalDateTime orderDate = LocalDateTime.now();
Order order = new Order(orderId, userId, orderDate, items);
orders.put(orderId, order);
for (OrderItem item : items) {
Product product = products.get(item.getProductId());
if (product == null || product.getStock() < item.getQuantity()) {
throw new IllegalArgumentException("Insufficient stock for product " + item.getProductId());
}
product.updateStock(-item.getQuantity());
}
return orderId;
}
// Method to cancel an order
public void cancelOrder(String orderId) {
if (!orders.containsKey(orderId)) {
throw new IllegalArgumentException("Order not found");
}
Order order = orders.get(orderId);
for (OrderItem item : order.getItems()) {
Product product = products.get(item.getProductId());
if (product != null) {
product.updateStock(item.getQuantity());
}
}
orders.remove(orderId);
}
// Method to list all orders
public List<Order> listAllOrders() {
return new ArrayList<>(orders.values());
}
// Method to find an order by ID
public Order findOrderById(String orderId) {
return orders.get(orderId);
}
// Method to list orders by user
public List<Order> listOrdersByUser(String userId) {
return orders.values().stream()
.filter(o -> o.getUserId().equals(userId))
.collect(Collectors.toList());
}
// Method to list recent orders
public List<Order> listRecentOrders(int limit) {
return orders.values().stream()
.sorted((o1, o2) -> o2.getOrderDate().compareTo(o1.getOrderDate()))
.limit(limit)
.collect(Collectors.toList());
}
// Method to list orders by date range
public List<Order> listOrdersByDateRange(LocalDateTime startDate, LocalDateTime endDate) {
return orders.values().stream()
.filter(o -> !o.getOrderDate().isBefore(startDate) && !o.getOrderDate().isAfter(endDate))
.collect(Collectors.toList());
}
// Method to add a user
public void addUser(String userId, String username, String password, boolean isAdmin) {
if (users.containsKey(userId)) {
throw new IllegalArgumentException("User already exists");
}
users.put(userId, new User(userId, username, password, isAdmin));
}
// Method to remove a user
public void removeUser(String userId) {
if (!users.containsKey(userId)) {
throw new IllegalArgumentException("User not found");
}
users.remove(userId);
}
// Method to update user password
public void updateUserPassword(String userId, String newPassword) {
User user = users.get(userId);
if (user == null) {
throw new IllegalArgumentException("User not found");
}
user.setPassword(newPassword);
}
// Method to list all users
public List<User> listAllUsers() {
return new ArrayList<>(users.values());
}
// Method to find a user by ID
public User findUserById(String userId) {
return users.get(userId);
}
// Method to list users by admin status
public List<User> listUsersByAdminStatus(boolean isAdmin) {
return users.values().stream()
.filter(u -> u.isAdmin() == isAdmin)
.collect(Collectors.toList());
}
// Method to list users by username
public List<User> listUsersByUsername(String username) {
return users.values().stream()
.filter(u -> u.getUsername().equals(username))
.collect(Collectors.toList());
}
// Main method to demonstrate functionality
public static void main(String[] args) {
ECommercePlatform platform = new ECommercePlatform();
// Adding products
platform.addProduct("P001", "Laptop", new BigDecimal("999.99"), 100);
platform.addProduct("P002", "Smartphone", new BigDecimal("499.99"), 200);
platform.addProduct("P003", "Tablet", new BigDecimal("299.99"), 150);
// Updating product stock
platform.updateProductStock("P001", 50);
// Removing a product
platform.removeProduct("P002");
// Listing all products
System.out.println("\\nList of Products:");
for (Product product : platform.listAllProducts()) {
System.out.println(product);
}
// Placing an order
List<OrderItem> orderItems = Arrays.asList(
new OrderItem("P001", 2, new BigDecimal("999.99")),
new OrderItem("P003", 1, new BigDecimal("299.99"))
);
String orderId = platform.placeOrder("U001", orderItems);
System.out.println("\\nOrder Placed: " + orderId);
// Canceling an order
platform.cancelOrder(orderId);
System.out.println("Order Canceled");
// Adding users
platform.addUser("U001", "alice", "password123", false);
platform.addUser("U002", "bob", "password456", true);
// Updating user password
platform.updateUserPassword("U001", "newpassword123");
// Listing all users
System.out.println("\\nList of Users:");
for (User user : platform.listAllUsers()) {
System.out.println(user);
}
// Listing users by admin status
System.out.println("\\nList of Admin Users:");
for (User adminUser : platform.listUsersByAdminStatus(true)) {
System.out.println(adminUser);
}
// Listing orders by user
System.out.println("\\nList of Orders by User U001:");
for (Order order : platform.listOrdersByUser("U001")) {
System.out.println(order);
}
// Listing recent orders
System.out.println("\\nRecent Orders:");
for (Order recentOrder : platform.listRecentOrders(3)) {
System.out.println(recentOrder);
}
// Listing orders by date range
LocalDateTime startDate = LocalDateTime.of(2023, 10, 1, 0, 0);
LocalDateTime endDate = LocalDateTime.of(2023, 10, 31, 23, 59);
System.out.println("\\nOrders Between " + startDate + " and " + endDate + ":");
for (Order order : platform.listOrdersByDateRange(startDate, endDate)) {
System.out.println(order);
}
}
}

@ -0,0 +1,390 @@
package self.cases.teams.teaa;
import java.time.Instant;
import java.util.*;
import java.time.LocalDate;
import java.util.stream.Collectors;
public class Managexiu {
private Map<Integer, User> users;
public Managexiu() {
users = new HashMap<>();
}
// Inner class to represent a User
public static class User {
private int userId;
private String name;
private String email;
private String password;
private LocalDate dateOfBirth;
private String address;
private String phoneNumber;
private boolean isActive;
public User(int userId, String name, String email, String password, LocalDate dateOfBirth, String address, String phoneNumber) {
this.userId = userId;
this.name = name;
this.email = email;
this.password = password;
this.dateOfBirth = dateOfBirth;
this.address = address;
this.phoneNumber = phoneNumber;
this.isActive = true;
}
public int getUserId() {
return userId;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public String getPassword() {
return password;
}
public LocalDate getDateOfBirth() {
return dateOfBirth;
}
public String getAddress() {
return address;
}
public String getPhoneNumber() {
return phoneNumber;
}
public boolean isActive() {
return isActive;
}
public void deactivate() {
this.isActive = false;
}
@Override
public String toString() {
return "User{" +
"userId=" + userId +
", name='" + name + '\\' +
", email='" + email + '\\' +
", password='" + password + '\\' +
", dateOfBirth=" + dateOfBirth +
", address='" + address + '\\' +
", phoneNumber='" + phoneNumber + '\\' +
", isActive=" + isActive +
'}';
}
public void setName(String newName) {
}
public void setEmail(String newEmail) {
}
public void setDateOfBirth(LocalDate newDateOfBirth) {
}
public void setPassword(String newPassword) {
}
public void setPhoneNumber(String newPhoneNumber) {
}
public void setAddress(String newAddress) {
}
public void setGroupName(String groupName) {
}
public Object getGroupName() {
return null;
}
public int getActiveFriendsCount() {
return 0;
}
public Instant getLastLoginDate() {
return null;
}
}
// Method to add a user
public void addUser(int userId, String name, String email, String password, LocalDate dateOfBirth, String address, String phoneNumber) {
if (users.containsKey(userId)) {
throw new IllegalArgumentException("User already exists");
}
users.put(userId, new User(userId, name, email, password, dateOfBirth, address, phoneNumber));
}
// Method to remove a user
public void removeUser(int userId) {
if (!users.containsKey(userId)) {
throw new IllegalArgumentException("User not found");
}
users.remove(userId);
}
// Method to list all users
public List<User> listAllUsers() {
return new ArrayList<>(users.values());
}
// Method to find a user by ID
public User findUserById(int userId) {
return users.get(userId);
}
// Method to deactivate a user
public void deactivateUser(int userId) {
User user = users.get(userId);
if (user == null) {
throw new IllegalArgumentException("User not found");
}
user.deactivate();
}
// Method to update user information
public void updateUser(int userId, String newName, String newEmail, String newPassword, LocalDate newDateOfBirth, String newAddress, String newPhoneNumber) {
User user = users.get(userId);
if (user == null) {
throw new IllegalArgumentException("User not found");
}
user.setName(newName);
user.setEmail(newEmail);
user.setPassword(newPassword);
user.setDateOfBirth(newDateOfBirth);
user.setAddress(newAddress);
user.setPhoneNumber(newPhoneNumber);
}
// Method to search for users by email
public List<User> searchUsersByEmail(String email) {
return users.values().stream()
.filter(u -> u.getEmail().toLowerCase().contains(email.toLowerCase()))
.collect(Collectors.toList());
}
// Method to search for users by phone number
public List<User> searchUsersByPhoneNumber(String phoneNumber) {
return users.values().stream()
.filter(u -> u.getPhoneNumber().equals(phoneNumber))
.collect(Collectors.toList());
}
// Method to search for users by date of birth
public List<User> searchUsersByDateOfBirth(LocalDate dateOfBirth) {
return users.values().stream()
.filter(u -> u.getDateOfBirth().equals(dateOfBirth))
.collect(Collectors.toList());
}
// Method to search for users by address
public List<User> searchUsersByAddress(String address) {
return users.values().stream()
.filter(u -> u.getAddress().toLowerCase().contains(address.toLowerCase()))
.collect(Collectors.toList());
}
// Method to search for users by active status
public List<User> searchUsersByActiveStatus(boolean isActive) {
return users.values().stream()
.filter(u -> u.isActive() == isActive)
.collect(Collectors.toList());
}
// Method to assign a user to a group
public void assignUserToGroup(int userId, String groupName) {
User user = users.get(userId);
if (user == null) {
throw new IllegalArgumentException("User not found");
}
user.setGroupName(groupName); // Assign default group
}
// Method to unassign a user from a group
public void unassignUserFromGroup(int userId) {
User user = users.get(userId);
if (user == null) {
throw new IllegalArgumentException("User not found");
}
user.setGroupName(null); // Set no group
}
// Method to list all users assigned to a group
public List<User> listUsersAssignedToGroup(String groupName) {
return users.values().stream()
.filter(u -> u.getGroupName() != null && u.getGroupName().equals(groupName))
.collect(Collectors.toList());
}
// Method to list all groups a user is assigned to
public List<String> listGroupsForMember(int userId) {
User user = users.get(userId);
if (user == null) {
throw new IllegalArgumentException("User not found");
}
return Arrays.asList(user.getGroupName().toString());
}
// Method to list all users with more than 10 active friends
public List<User> listUsersWithMoreThanTenActiveFriends() {
return users.values().stream()
.filter(u -> u.getActiveFriendsCount() > 10)
.collect(Collectors.toList());
}
// Method to list all users who are active in any group
public List<User> listActiveUsersInAnyGroup() {
return users.values().stream()
.filter(u -> u.isActive())
.collect(Collectors.toList());
}
// Method to list all users that have been registered within the last month
public List<User> listRecentRegistrations() {
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
return users.values().stream()
.filter(u -> !u.getDateOfBirth().isBefore(oneMonthAgo))
.collect(Collectors.toList());
}
// Method to list all users with more than 10 active friends in the last year
public List<User> listUsersWithMoreThanTenActiveFriendsInLastYear() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getActiveFriendsCount() > 10 && u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year
public List<User> listUsersLoggedInInLastYear() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last month and have more than 10 active friends
public List<User> listUsersLoggedInInLastMonthWithMoreThanTenActiveFriends() {
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneMonthAgo)) && u.getActiveFriendsCount() > 10)
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriends() {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10)
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroup(String groupName) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddress(String groupName, String address) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumber(String groupName, String address, String phoneNumber) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActive(String groupName, String address, String phoneNumber) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive())
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificName(String groupName, String address, String phoneNumber, String name) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmail(String groupName, String address, String phoneNumber, String name, String email) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPassword(String groupName, String address, String phoneNumber, String name, String email, String password) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email) && u.getPassword().equals(password))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirth(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email) && u.getPassword().equals(password) && u.getDateOfBirth().equals(dateOfBirth))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddress(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email) && u.getPassword().equals(password) && u.getDateOfBirth().equals(dateOfBirth) && u.getAddress().equals(addressDetail))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address and phone number
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddressAndPhoneNumber(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail, String phoneNumberDetail) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email) && u.getPassword().equals(password) && u.getDateOfBirth().equals(dateOfBirth) && u.getAddress().equals(addressDetail) && u.getPhoneNumber().equals(phoneNumberDetail))
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address and phone number and are active
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddressAndPhoneNumberAndActive(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail, String phoneNumberDetail) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email) && u.getPassword().equals(password) && u.getDateOfBirth().equals(dateOfBirth) && u.getAddress().equals(addressDetail) && u.getPhoneNumber().equals(phoneNumberDetail) && u.isActive())
.collect(Collectors.toList());
}
// Method to list all users who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address and phone number and are active and have a specific name and email and password and date of birth and address and phone number
public List<User> listUsersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddressAndPhoneNumber(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail, String phoneNumberDetail) {
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
return users.values().stream()
.filter(u -> u.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && u.getActiveFriendsCount() > 10 && u.getGroupName().equals(groupName) && u.getAddress().equals(address) && u.getPhoneNumber().equals(phoneNumber) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email) && u.getPassword().equals(password) && u.getDateOfBirth().equals(dateOfBirth) && u.getAddress().equals(addressDetail) && u.getPhoneNumber().equals(phoneNumberDetail) && u.isActive() && u.getName().equals(name) && u.getEmail().equals(email) && u.getPassword().equals(password) && u.getDateOfBirth().equals(dateOfBirth) && u.getAddress().equals(addressDetail) && u.getPhoneNumber().equals(phoneNumberDetail))
.collect(Collectors.toList());
}
}
Loading…
Cancel
Save