Perpustakaan Sederhana dengan Java
Perpustakaan Sederhana dengan Java
In Source 1, the implementation for handling book borrowing uses a fixed array of book titles and implements book ID selection directly by mapping array indices with user input, which simplifies the borrowing process. The rental fees are calculated based on conditional logic tied to hardcoded book ID ranges. In contrast, Source 2 expands on this functionality by implementing additional nested choices for book selection beyond a single array, allowing users to choose specific book types and subcategories. Source 2 also involves multi-step input processes with nested switch-case statements to accommodate detailed choices and conditions in rental operations .
The InputKeyboard class in the TextBase library program acts as a utility for handling user input from the console. It facilitates interactions by providing methods that allow reading and parsing inputs entered by users for different operations, such as member registration and book borrowing processes. Its presence helps abstract input operations away from the main logic, contributing to a cleaner and more maintainable codebase .
The rental fees for books in the TextBase library system are determined by the type of book selected. For a type 1 book (Kamus), the fee is set at 3000; for a type 2 book (Majalah), the fee is 1000; and for any other book type, the fee is 2000 per week . The system uses conditional statements to assign the appropriate rental fee based on the user's book selection .
The TextBase library system calculates a penalty for overdue book returns by determining how many days beyond the allowed rental period the book was returned. The allowed rental period is 7 days, and if the book is returned late, the system calculates the excess days and multiplies them by a penalty rate of 500 per day. If returned within the time frame, no penalty is charged .
The program utilizes control structures, such as 'switch-case' statements, to handle user actions like book borrowing and returns. These control structures allow the program to provide automatic feedback by executing specific blocks of code based on the user's menu selections. For example, when a user selects the borrowing option, the corresponding case in the switch statement processes the request, calculates rental fees, displays the selected book, and presents a rental confirmation with costs. This control flow ensures that every user selection results in immediate, contextually relevant feedback .
The TextBase library system handles inputs by prompting users for necessary data through direct console inputs, which are processed using InputKeyboard methods. It mitigates errors by offering clear instructions and possible options for each input stage. For instance, lists of books for selection and confirmation messages after data entry guide users through the process, minimizing potential errors. The structured format of user menus and conditional checks on inputs serve to catch and manage incorrect entries interactively .
The TextBase library system ensures a user-friendly interface for book selection by displaying a clear menu with numbered options representing the different types of books available for borrowing. Users can see a list of book titles with associated numbers, making it easy to select a book by entering its corresponding number. The interface provides immediate feedback on the selected book and associated rental cost, thus facilitating informed decision-making .
The TextBase library system provides a new member registration procedure that involves inputting the member's ID number, name, address, and phone number. This information is then stored, and a confirmation message is displayed indicating that the member's data has been saved .
The design of the Java-based library system supports effective management of book lists and borrowing records by using arrays to store book titles, which simplifies retrieval and display operations. The system also uses structured switch-case logic to manage different user actions such as borrowing, returning, and viewing books, ensuring that user inputs lead to the correct processes. This compartmentalization aids in maintaining clarity and order within both user-facing operations and backend processing .
Using static arrays for managing book data in the TextBase library system offers simplicity and fast access times for predefined book lists, making it efficient for small and relatively static datasets. However, this approach limits scalability and flexibility, as arrays have a fixed size and cannot dynamically grow to accommodate more books or changes in book information. Additionally, a static array does not naturally support associative data operations, which could be necessary for more complex library systems involving multiple attributes per book .