Comments (2)
The transaction object is what you need to link Account
, Item
, and the borrowing state together.
class Transaction {
Account account;
Item item;
boolean returned = false;
void resolve() => returned = true;
// Something for setting returned to false here
// or just change it to setReturned(bool state) for simplicity.
}
If you want to perform a rent action, it would be best served on an Account object. Think of it like this:
if (PersonA.canRent(book1)) // Only check if this account can rent the given item
PersonA.rent(book1); // Create a transaction and call ItemManager.decreaseStock(book1)
Which is a valid case for using the rent() method on the Account without the much-needed confusion. For handling the decreasement of items, just call ItemManager.decreaseStock(book1)
, which by default decreases the item's stock by 1.
NOTE: You can also create an overloaded function:
void decreaseStock(Item item, int amount);
to decrease the stock by any amount of your choice.
Those are just a few basic ideas you'll have to keep in mind. Let me know if you need more clarifications on this topic, I'll be happy to help.
from video-store-manager.
@vhpx I have some confusions:
-
Where can we put the method that perform renting item and returning item? In Account class or Transaction class?
If in Account class, we will check if that item is possible to be rented or not then decrease numCopy and add to current rental list. After that, we will create the transaction.
If in Transaction class, this class is responsible for all the checking and other tasks like decrease/add when Account call rentItem. -
Do we need to have add a list of transaction as attribute of Account class?
from video-store-manager.
Related Issues (15)
- Change wildcard imports to specific import to avoid wasting resources on unnecessary imports. HOT 4
- Missing some authentication functionalities
- The main README file inside `docs` folder needs to be updated HOT 2
- Account constructor class and its methods are missing exception handlers HOT 1
- Account class is missing some CRUD and other necessary methods HOT 3
- Missing UI components & screens HOT 2
- Dependency Dashboard
- Missing functions to display Item HOT 2
- Missing functions related to Account class (role promotion, search, etc...) HOT 3
- Should we change the type of rentalStatus? HOT 4
- Need some clarifications about renting and calculating points HOT 8
- Missing common components (menu, button, input, dropdown, ... )
- Missing unstyled screens HOT 1
- Missing loading indicator when doing resource-intensive operations like I/O, searching, and filtering
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from video-store-manager.