public class LibraryCollection { private int collectionMaxSize; private Material[] libraryCollection; public LibraryCollection(int theMaxSize) { collectionMaxSize = theMaxSize; libraryCollection = new Material[collectionMaxSize]; } public LibraryCollection(int theCollectSize, Material[] theArray) { collectionMaxSize = theCollectSize; libraryCollection = theArray; } //Material ID & checkedOutPtron ID; public boolean checkOutMaterial(String matrlID, String patronId) { Material thisMaterial = findMaterial(matrlID); if (thisMaterial == null) { System.out.println("The material doesn't exist"); return false; } if (thisMaterial.checkedOut()) { System.out.println("The material has been already checked out "); return false; } thisMaterial.setCheckedOut(true); thisMaterial.setPatronCheckout(Integer.parseInt(patronId));//Convert string value into int return true; } }
public class Material { private static int materialID = 0; private int mtrId; private String title; private boolean checkedOut; private int checkedOutPatron; public Material() { mtrId = 0; title = ""; checkedOut = false; checkedOutPatron = 0; } public Material(int theId, String theTitle) { mtrId = theId; title = theTitle; } //Getter Method public String getMaterialId() { return mtrId + ""; } public String getTitle() { return title; } public void setCheckedOut(boolean theCheckout) { checkedOut = theCheckout; } public void setPatronCheckout(int patronCheckout) { checkedOutPatron = patronCheckout; } public boolean checkedOut() { return checkedOut; } public int getCheckedOutPatron() { return checkedOutPatron; } //ToString Method public String toString() { return " \nMaterial ID: " + mtrId + " \nMaterial Title: " + title + " \nChecked Out: " + checkedOut + " \nPatron check out: " + checkedOutPatron; } public static int getNextID() { materialID++; return materialID; } }
public static LibraryCollection librarycollectObj1 = new LibraryCollection(10);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)