Apps214: Stocks - BNU-CO452/bluej-apps21-Miridicent GitHub Wiki

App21-04: Stock Application (with console based UI)

Students need to take a copy of this wiki page for their documentation, See Wiki Documentation which has a link to a video demonstration

Java IDEs

This is the first app that has a user interface, and therefore does not need to use the BlueJ Object-Bench which is a unique feature of BlueJ. Some students might like to switch to a professional Java IDE at this point. The recommended IDE is IntelliJ, please read the Java IDE wiki page and use this IntelliJ Template Repository

IJ Image

Description

This is the first BlueJ application that will offer a user interface so that the application can be run by a user without using the BlueJ Object Bench. It is based on the ProductList which contained a list of products that were being delivered and sold.

This application uses the StockDemo, ProductList and Product classes from App03 and adds a user interface class StockApp and a Program class which can be used to run the application without having to create any objects first. The StockDemo is used to provide test data in the form of a list of 10 products. Please use "Add class from file" in BlueJ to copy those classes from App21-03-products into the App21-04-stock folder and then restart BlueJ if you are using it.

The InputReader class is there to assist simple user input in the terminal window sometimes referred to as the console or command window.

Class Diagram

Requirements

"Running" a Java Program

The application should be a standard Java Application with a Program class and a main() method which can be used without creating a Program object. The main() method in the Program class should create a StockApp which can print out a simple heading with the name of the application and the author name (you) and a menu of choices for the user. It should look something like what is shown below

public class Program
{
    private static StockApp app;
    
    public static void main(String[] args)
    {
        app = new StockApp();
        app.run();
    }
}

Program Heading

Most methods accessed by the user should include good, clear messages to the user (System.out.println), and any method should print out messages to the user that cover most of the simple mistakes a user could make. Marks will be deducted for unclear or incomplete messages to the user.

Basic Requirements - User Menu

The first feature that is required by the user is to be offered a menu of choices. The user will enter their choice as a word, and in the first instance the menu can just offer the following choices:-

  1. Add Product to Product List
  2. Remove Product by ID
  3. Print all the products
  4. Quit the application

Main Requirements

Once the basic menu is working then extend the menu to offer the following additional features.
You may want to use the StockDemo class to add more products to the stock to make testing easier.

  1. Remove find a product by id and remove it from stock list.
  2. Buy a quantity of product (between 1 and 10)
  3. Sell a quantity of product (between 1 and 10)
  4. Print all the products in stock
  5. Search and print a list of products based on part of the product name
  6. Low Stock print a list of products whose stock levels are low (between 1 and 5)
  7. Quit the application

Advanced Requirements

  1. Re-Stock Re-stock all the low stock items up to a set minimum level

Program Design

UML: Use Case Diagram

UML: Use Case Diagram

UML: Class Diagram (10 marks)

Visual Paradigm

Visual Paradigm is a full CASE (Computer Aided Software Engineering) tool that can generate code from diagrams and diagrams from code. Only the Standard Edition and above can create a class diagram from java code. So you can use that by downloading and installing the 1 month free trial edition or use the Enterprise Edition from BucksAnywhere.

Please watch this video How to Create Class and Use Case Diagrams using Visual Paradigm

The student must replace this UML diagram with their own class diagram!

UML: Class Diagram

Testing

Black Box Testing (10 marks)

The student must complete the following black box tests. The actual product name and id can be changed

Test No Proposed Test Data Entered Expected Result Actual Result Comments
01 Print products "print" 10 Products printed 10 Products printed
02 Quit App "quit" Application ends Application ends
03 Add Product "add", new ID and name Product added Product added
04 Add Product "add", existing ID Error Message Error Message
05 Remove Product "remove", existing ID Product Removed Product Removed
06 Remove Product "remove", non-existing ID Error Message Error Message
07 Buy Product "buy", id = 100, amount = 4 Stock increased by 4 Stock increased by 4
08 Sell Product "sell", id = 100, amount = 4 Stock decreased by 4 Stock decreased by 4
09 Search Products "search", name = "xxx" Products that match "xxx" Products that match "xxx"
10 Low stock Products "low stock", quantity = 1 List of low stock products List of low stock products
11 Re-stock Products "re-stock", quantity = 1 List of products re-stocked List of products re-stocked

The student must provide a link to a text file recording (or recordings) of this testing from a terminal window
Tests1-6.png Tests 1 to 6.txt
Tests1-6.png Tests 7 to 11.txt

Evaluation (10 Marks)

Imagine that Amazon were considering switching to use your java application, name the 5 most important features that you would need to add in order for it to be useable to Amazon

  1. It could use a save stock function to save each users stock rather than having to hard code it in for every user
  2. It could use popularity statistics to show which products are the most popular and thus inform the user to stock more of them
  3. As mentioned before a stockpile function to keep products in reserve would no doubt be incredibly helpful
  4. Only one thing can be added or removed at a time, this could benefit from a function that allows you to add or remove multiple products at the same time
  5. If the quit function is used at any time that isn't the menu then an error will occur, if people are in a hurry then they may want to be able to quit off at anytime without causing the program to crash