Java shopping cart software
Test; import uk. DiscountType; import uk. Improve this question. Better use BigDecimal. See also stackoverflow. Indeed I should be using BigDecimal. I will make the correction. Is there anything from the design perspective I am missing here? Any thoughts? Add a comment. Active Oldest Votes. Initializing class fields to null is unnecessary and duplicate as they are automatically initialized to null default value setup would be a better place to setup your products.
Don't use field and variable names like map , list. They need to speak to whomever is reading the code. I have no idea what your map represents. I would like this code to be improved to be readable with less effort. Use assertArrayEquals float[] expecteds, float[] actuals, float delta for comparing floats. Improve testApply2For1Offer test. There you put elements to the map but it is not clear how the map interacts with the rest of the code.
This does not seem right. I would think that there is only one Discounts object that can calculate a discount or final price for a given Basket. This is the biggest issues I see here, the design of the Basket. Powerful Administration Sophisticated and powerful role based administration application. Low Cost of Ownership Upgrade to future versions without changing your storefront code. Support and Services Professional Services and Support packages available.
Read more in the features section. Product Is KonaKart for you? Community or Enterprise? Demos Downloads Community Edition Ver 9. Since this is for an OOP assignment, I don't want to take you too far without learning the basics. You should look into classes and inheritance and polymorphism.
You cart should contain a list of instances of type item. Each instance will be of a specific derived item type. The Catt should be able to process the list and use logic to apply the discounts. Discounts themselves could also be there own classes and the cart could determine which ones to apply to the total. Start small, test and then expand the solution.
Maybe start with one type of item and the discount for that. Then add the others. Also you will probably get partial credit for any working example so use source code tool or keep backups of working solutions to be able to hand it in. Add a comment. Active Oldest Votes. Improve this answer. Ewan Ewan Right in theory I do see what you're saying and it does make sense. Although i'm finding it hard to see how i could possibly implement the Offer class?
I have worked at more than one large e-company. I see yes, that is something which was required was making a system that could work well with offers that would constantly change.
Would you say first step to possible have a class which would store all the items? Show 3 more comments. Lessons learned, up front: Don't over analyze.
It's clear an item Product has a name and price. The rest will evolve with the overall design. ToString in particular when you know there is output, like a receipt. Each class should worry only about how to output itself. Single Responsibility Principle at its most fundamental. Signs of good design: small classes small methods more classes because each has a "single responsibility" These traits tend to just happen as a consequence of making good self-responsible classes.
Equals otherProduct. Product is just a "thing". A product knows about itself. It should not know about the Cart and its other contents.
0コメント