src/Model/Inventory.java
// Lookup parts by Part ID or Part Name
Lookup parts by Part ID or Part Name
Lookup parts by Part ID or Part Name
public static int lookupProduct(String productSearch) {
        boolean productFound = false;
        int productIndex = 0;
        if (validInt(productSearch)) {
            for (int i = 0; i < allProducts.size(); i++) {
                if (Integer.parseInt(productSearch) == allProducts.get(i).getId()) {
                    productIndex = i;
                    productFound = true;
                }
            }
        } else {
            for (int i = 0; i < allParts.size(); i++) {
                productSearch = productSearch.toLowerCase();
                if (productSearch.contains(allParts.get(i).getName().toLowerCase())) {
                    productIndex = i;
                    productFound = true;
                }
            }
        }
        if (productFound == true) {
            return productIndex;
        } else {
            System.out.println("ERROR: Unable to locate any products based on the given search parameters.");
            return -1;
        }
    }
public static int lookupProduct ( String productSearch ) { boolean productFound = false ; int productIndex = 0 ; if ( validInt ( productSearch ) ) { for ( int i = 0 ; i < allProducts . size ( ) ; i ++ ) { if ( Integer . parseInt ( productSearch ) == allProducts . get ( i ) . getId ( ) ) { productIndex = i ; productFound = true ; } } } else { for ( int i = 0 ; i < allParts . size ( ) ; i ++ ) { productSearch = productSearch . toLowerCase ( ) ; if ( productSearch . contains ( allParts . get ( i ) . getName ( ) . toLowerCase ( ) ) ) { productIndex = i ; productFound = true ; } } } if ( productFound == true ) { return productIndex ; } else { System . out . println ( "ERROR: Unable to locate any products based on the given search parameters." ) ; return - 1 ; } }
Lookup parts by Part ID or Part Name
Lookup parts by Part ID or Part Name