/// <summary> /// Search for a Part in Inventory. If the PartID is nonexistant, it returns a dummy object with the ID -1 /// </summary> /// <param name="PartID"></param> /// <returns>A Part Object</returns> public Part lookupPart(int PartID) { foreach (Part aPart in allParts) { if (PartID == aPart.getPartId()) { return(aPart); } } //Create a dummy Variable with the partID as -1 to use as an error check. Developer can check for -1 to notify user that part doesn't exist. Part dummyPart = new Inhouse(); dummyPart.setPartID(nonExistantID); return(dummyPart); }
/// <summary> /// Returns the Part that matches the Part ID entered as a parameter. If the function returns a Part with PartID = -1, there is no match /// </summary> /// <param name="associatedPart"></param> /// <returns></returns> public Part lookupAssociatedPart(int associatedPart) { //Cycle through list of Associated Parts to see if the int given matches the ID of a part in the list foreach (var part in associatedParts) { if (part.getPartId() == associatedPart) { return(part); } } //Create a dummy Variable with the partID as -1 to use as an error check. Developer can check for -1 to notify user that part doesn't exist. Part dummyPart = new Inhouse(); dummyPart.setPartID(nonExistantID); return(dummyPart); }