Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need some clarifications about renting and calculating points #21

Closed
thu-ngx opened this issue Aug 27, 2022 · 8 comments
Closed

Need some clarifications about renting and calculating points #21

thu-ngx opened this issue Aug 27, 2022 · 8 comments

Comments

@thu-ngx
Copy link
Collaborator

thu-ngx commented Aug 27, 2022

image

  • In the requirements, guest account can only rent maximum 2 items AT A TIME. So how can we convert AT A TIME into code? When we call the function rent(Item), each transaction is separate.

  • When VIP has >= 100 reward points -> rent 1 item for free means that all accounts has to pay for their rentals. My question is how would they pay for their rentals?

  • Only VIP accumulate reward points, so do we need to add another attribute point ? Then how much point each account will receive or be deducted when making rentals?

@vhpx

@HPOKSG
Copy link
Collaborator

HPOKSG commented Aug 27, 2022

For the first question, I think for every account, we gotta have an list where we track what items that the account itself
currently borrowing. I know it violated the encapsulation rule that I discussed with Phuc before, but it could be the way.

@vhpx
Copy link
Owner

vhpx commented Aug 27, 2022

I'm having lunch right now, I'll check back and reply later.

@thu-ngx
Copy link
Collaborator Author

thu-ngx commented Aug 27, 2022

Oh I misunderstood "at a time" sr. For that, we currently have a list for currentRentals, and the size of that list must be <= 2 for guest account. I thought it was "not to rent 2 items literally at 1 specific time".

@thu-ngx
Copy link
Collaborator Author

thu-ngx commented Aug 27, 2022

@vhpx What do you think?

@vhpx
Copy link
Owner

vhpx commented Aug 27, 2022

For most of the requirements, I think a simple canRent(item) would do the trick.

As for account promotions, let's have AccountManager manage the process.

public void levelUp(Account account) {
    if (account.role == "VIP") return;

   int resolvedTransactions = transactionManager.getTransactions(account, true);

    if (account.role == "REGULAR" && resolvedTransactions >= 5) {
        account.setRole("VIP");
        return;
    }

    if (account.role == "GUEST" && resolvedTransactions >= 3) {
        account.setRole("REGULAR");
        return;
    }

for the transactionManager.getTransactions() method, you can assume it's like this:

public ArrayList<Transaction> getTransactions(Account account);
public ArrayList<Transaction> getTransactions(Account account, boolean resolved);

@vhpx
Copy link
Owner

vhpx commented Aug 27, 2022

About the VIP account with the points system. Add the int points attribute ONLY to VIPAccount. Then override the rent() method inside it with point-related expressions, which should be straightforward from this point.

@thu-ngx
Copy link
Collaborator Author

thu-ngx commented Aug 27, 2022

@vhpx How would accounts pay for their rentals? Should we add another attribute which will be deducted when renting and increase when returning?

@vhpx
Copy link
Owner

vhpx commented Aug 27, 2022

That could work. Design it the way it make sense to you and I'll take a look.

@thu-ngx thu-ngx closed this as completed Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants