import java.util.*; import java.io.*; public class Library { /** * Description: This Program take book names, its writer and isbn from a library.txt file. * you can list books by its writer, also take and return it. * you must include the library.txt file in the same folder. * Author: Naqibullah Danishjo. * Date: 06/01/2010 at 02:45 * contact: danishjo.webs.com * E-mail: danishjo@yashlar.net * * library.txt Example : copy the text bellow and paste in a text file called library. you can add * more books in this format. * Gazali KimyayiSaadet 252525 * Mawlana Mathanawi 246896 * Sadi Gulistan 121223 * Attar PandNama 454554 * Hafez DiwanHafez 787878 * Nizami Ganjnama 458569 * sadi bostan 25345 */ public static void main(String[] args) throws FileNotFoundException { char select='0'; System.out.println("\t\t\tWelcome To Danishjo Library"); System.out.println("\t\t\t***************************"); System.out.println("___________________________"); file("library.txt"); select= menu(); while (select != '6') { if (select == '1') { // get book method int get=getBook(); if (get==1){ System.out.println("Book Succesfully Has Gotten."); System.out.println("___________________________"); } else if(get==-1){ System.out.println("Book not found!"); System.out.println("_______________"); } else if(get==0){ System.out.println("Book has already been taken."); System.out.println("____________________________"); } } else if (select == '2') { // list all book listAll(); } else if (select == '3') { //list by writer if (!byWriter()) { System.out.println("No Book For The Given Writer"); System.out.println("_____________________________"); } } else if (select == '4') { // return book int get2 = returnBook(); if(get2==1){ System.out.println("book successfully returned"); System.out.println("___________________________"); } else{ System.out.println("Sorry. Book not found!!"); System.out.println("_______________________"); } } else if(select=='5'){ if (!FindBook()) { System.out.println("Book Not Found"); System.out.println("_______________"); } } else { // invalid selection// System.out.println("INVALID SELECTION. PLEASE ENTER THE NUMBER RESPECT TO THE ACTION"); } select = menu(); } System.out.println("\t\t_________Thank you for using our Library_______"); } public static boolean FindBook(){ Scanner input = new Scanner(System.in); System.out.print("Book name required : "); String book = input.next(); for(int i=0; i