Stock Management System Here, the complete Java code has been presented for a Stock Management System using the concept of OOPS ( Object Oriented Programming). Description of the overall solution and working: The class ‘warehouse’ stores the stock items as well as transactions list. The class ‘Stock Sale Transaction’ stores the stock, price as well as quantity. The class ‘Stock Purchase transaction’ stores the stock, price as well as quantity. The class ‘stock adjustment transaction’ stores the stock and the quantity. It helps to add or remove the stock. The class ‘stock’ stores the name, code and quantity in stock for an item. The class ‘transactions’ is an abstract class. In class ‘program’, a menu is displayed and the user is asked to enter an option from 1 - 6 to choose the desired action to be performed. Based on the option chosen by the user, the desired action is performed ( using switch statement ). Relation to key principles of object oriented programming: Abstraction: It occurs when only few essential details are shown and other details are hidden from the user. An abstract class is used for this. It cannot be used for the creation of objects. In order to access it, it needs to be inherited from any other class.
In the given code it is seen as follows: In the abstract class ‘transactions’, certain data is protected ( like stock, price, quantity) , certain data is private and some data is public. Encapsulation: The data of object can be accessed only through the functions of the object. This makes the data safe and hides it. It does not allow other objects to cause any changes. In the given program, at various places the keyword ‘private’ makes the data or functions accessible only within the class and not outside. Inheritance: In case of inheritance, a new class is created ( also called derived class ) from an already existing class ( also called base class). The derived class has the properties of the base class as well as its own properties (Anigbogu, 2011). In the given case, the classes – Stock Adjustment Transaction, Stock Purchase Transaction and Stock Sale Transaction are inherited from class Transactions. Polymorphism: It is said to occur if an operator or a function is used in many ways and forms. It depends on the data on which they operate (Ogirima, 2014). In the given code, the functions show polymorphism.
References Anigbogu, S.O., Francisca, O.O. and Usman, K., 2011. An intelligent model for sales and inventory management.Indian Journal of Computer Science and Engineering,2(5), pp.785- 791. Ogirima,S.A.O.,Awode,T.R.andAdeosun,O.O.,2014.Onlinecomputerizedhotel management system.J. Comput. Biosci. Eng., ISSN, pp.2348-7321.