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 lookupPart(String partSearch) {
        boolean partFound = false;
        int partIndex = 0;
        if (validInt(partSearch)) {
            for (int i = 0; i < allParts.size(); i++) {
                if (Integer.parseInt(partSearch) == allParts.get(i).getId()) {
                    partIndex = i;
                    partFound = true;
                }
            }
        } else {
            for (int i = 0; i < allParts.size(); i++) {
                partSearch = partSearch.toLowerCase();
                if (partSearch.contains(allParts.get(i).getName().toLowerCase())) {
                    partIndex = i;
                    partFound = true;
                }
            }
        }
        if (partFound == true) {
            return partIndex;
        } else {
            System.out.println("ERROR: Unable to locate any parts based on the given search parameters.");
            return -1;
        }
    }
public static int lookupPart ( String partSearch ) { boolean partFound = false ; int partIndex = 0 ; if ( validInt ( partSearch ) ) { for ( int i = 0 ; i < allParts . size ( ) ; i ++ ) { if ( Integer . parseInt ( partSearch ) == allParts . get ( i ) . getId ( ) ) { partIndex = i ; partFound = true ; } } } else { for ( int i = 0 ; i < allParts . size ( ) ; i ++ ) { partSearch = partSearch . toLowerCase ( ) ; if ( partSearch . contains ( allParts . get ( i ) . getName ( ) . toLowerCase ( ) ) ) { partIndex = i ; partFound = true ; } } } if ( partFound == true ) { return partIndex ; } else { System . out . println ( "ERROR: Unable to locate any parts based on the given search parameters." ) ; return - 1 ; } }
Lookup parts by Part ID or Part Name
Lookup parts by Part ID or Part Name