/** * This tests to see if the video can be checked out. It will check: If the customer has fees (If * yes, return false). If the videoID is in the database (If no, return false). If the videoID is * available for rent (If no, return false). If the customer has at least 3 videos already checked * out (If yes, return false). * * <p>Thus, if the result is false, the video can not be checked out for one of those four * reasons. If true, the video is ready to be checked out. * * @param videoID * @param customerCardID * @return False if video can not be checked out. True if video can be checked out. */ public static boolean canCheckoutVideo(String videoID, String customerCardID) { for (int i = 0; i < videos.size(); i++) if (!AVSCustomerDatabase.getCustomer(customerCardID).hasFee()) if (videoID.equals(videos.get(i).getVideoID())) if (getVideo(videoID).getCustomerCardID() != null) if (getCheckedOutList(customerCardID).size() < 3) return true; return false; }
/** * This checks in a video. This method will find the checked out copy in the array, match the * Video and Customer ID's, check to see if there needs to be an overdue and/or damaged fee, and * charges any fees to the customer. If video is damaged, the video is removed from the database. * * <p>After charging fees, the customer is removed from the video and the daysOut is reset. * * @param videoID * @param customerCardID * @param damaged */ public static void checkinVideo(String videoID, String customerCardID, boolean damaged) { for (int i = 0; i < videos.size(); i++) { if (videoID.equals(videos.get(i).getVideoID()) && customerCardID.equals(videos.get(i).getCustomerCardID())) { if (videos.get(i).isOverdue()) { AVSCustomerDatabase.getCustomer(customerCardID) .chargeFee(getVideo(videoID).getOverdueFee()); } if (damaged) { AVSCustomerDatabase.getCustomer(customerCardID) .chargeFee(getVideo(videoID).getDamagedFee()); removeVideo(videoID); } videos.get(i).setCustomerCardID(null); videos.get(i).resetDaysOut(); break; } } }