Java: Store Inventory

Object Oriented Programming

Programming projects are always a favourite of mine. They normally come with moments of frustration but overall I thoroughly enjoy the problem solving. During my time as an undergrad, the majority of my programming projects were artistically driven. This meant that I often was happy as long as the output was doing what it was supposed to be doing. There was a balance between back end functionality and user interface design and for that purpose I primarily used procedural programming.

However, I always felt as if I could dig deeper into understanding programming. Object Oriented Programming is something I have previously implemented into my projects but it was a technique that was not my best strength. An understanding of objects and classes is integral to a programmer. It allows for chunks of code to be re usable and provide clarity to the system.

The Project Objective

Apply an object-oriented approach to the design and development of a small software application.

System Requirements

A local charity shop requires a system to manage its intake and the sale/hire of the items it stocks. The system will be used by employees (shop assistants and managers) of the store.

An employee should initially be presented with a login message. The employee logs in as either a shop assistant or a manager.

After logging in, a shop assistant should be able to initiate a transaction by entering a list of codes for items and associated quantities. The system should check the stock to see if each item is in stock. If it is, then appropriate details with respect to the item and the quantity should be output to the screen. The total cost of the transaction should also be output. An option to purchase/hire items should also be presented. If the customer agrees to continue with the transaction, then an appropriate receipt including date and time of the transaction, item code/name, quantity, unit cost and total cost should be issued. The stock should be updated to reflect the transaction. The system should keep track of the items and quantities involved in each transaction. Additional charges should apply if items hired are not returned by the due date.

A manager in the store can retrieve the following information from the system:

  • A summary of all items currently in stock
  • Details related to specific items in stock – Subclasses
  • A summary of all sales/hires over a chosen period of time (days/weeks/months/years)

The system should keep track of stock, sales and employee details. This information should be stored in external csv files. The names of these files should be supplied when the application is run.

Process

My initial step was to assess the requirements in order to gain an understanding as to what nouns and verbs are involved. This assessment contributes to the decision of what classes and methods are required. Netbeans 8.0.2 was used for this project. It comprised of 10 classes (including the main class) and could read/write multiple text files in order provide information to the user interface.

Main Class

Creates a CSVFile object, passing the String names of the text files located in the folder. Files are then added to appropriate lists, passed onto Menu class object in order to be accessed via the text interface.

CSVFiles Class

The class takes the String arguments from the main method. It reads through 5 of the text files separately and adds the data into individual array lists. Once the program is exited, it updates each text file with changes made to each list during user interaction.

MenuInterface Class

This class displays information to the user and prompts them to interact.  It gives visual feedback and communicates with other classes in order to access lists and display results of changes made. It takes the files from the CSVFile object created giving access to all lists and passes those lists onto Transaction class.

Transaction Class

This class adds to the items sold and items rented lists. It also can display the overall information of transaction records. It creates specific selected items objects for each transaction.

Stock Class

This is the blueprint for all the items that are in stock. Their information is stored in the text file. The information is passed to here to assign values to each property. Product information can be accessed and mutated here i.e the quantity of each product.

SelectedItemSale Class

This class deals with the specific item that is being logged in the sales arraylist. It allows access to specific information regarding the transaction detail.

SelectedItemRent Class

This class deals with items that have been selected by the user to be logged in the rental array list. It is a subclass to SelectedItemSale It calculates  and displays when a product has been rented and when if should be returned.  It updates the transaction status for the agreement and incurs a penalty for late returns.

Employee Class

This is a super class for specific employee subclasses. It is the blueprint for employee information

FullTimeEmployee Class

Employee is its super class. This class is the blueprint for all the full time staff employees. It has properties which can be accessed or mutated. The salary and job description are what extras it has.

FullTimeEmployee Class

Employee is its super class. This class is the blueprint for all the part time staff employees. It has properties which can be accessed or mutated. The hours and training status are what extras it has.

Skills Enhanced

  • Classes, constructors and objects
  • Accessors and Mutators
  • Read/Write to text files
  • Overloading Methods
  • Enhanced for loops
  • private, public and protected
  • UMLs
  • Data Class: comparing
  • Encapsulations, Inheritance, Aggregation and Polymorphisms
  • Strings : splitting, comparing, concatenation etc.
  • Much more

Demonstration