individual-project-Neeraj-MSSJ created by GitHub Classroom
To implement a grocery mart java application that allows users to add and purchase products.
- Clone the repo to your folder.
- Open the folder in IDE.
- Execute the following commands in /src folder: javac Billing.java and java Billing.
- Enter the path of your input file.
- Output.csv file will be generated in /src folder which has total price and an error.txt file is generated with logs.
- Singleton Pattern
- Chain of Responsibility
- Factory
The pattern ensures that a single class is responsible for creatinf only one object and provides a way to access the object directly without needing intitiation of the class object. In our application, Singleton is used to cap values for categories i.e. Essential, Luxury and Misc. getInstance() method is used to obtain the cap values.
The pattern ensures that a request from the client is passed to a chain of objects to process them. The object in the chain will decide the the order of chain and whether the request needs to be passed down the chain or not. Chain of Responsibility is used to validate the quantity and price of the product in a chained process. After the quantity and cap is validated, total price will be calculated.
The pattern provides an interface which allows subclasses to change the type of objects in the superclass. Factory is used to read the input file and dataset. InputReader reads the input files and ReadData class reads dataset file when Handler determines which class to read.
Note: The cap value are set as follows, Essentials: 20, Luxury: 10 and Misc: 10.