Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.89 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class project_lamia {
  4.  
  5.     /**
  6.      * @param args
  7.      */
  8.     public static void main(String[] args) {
  9.         // TODO Auto-generated method stub
  10.         int option;
  11.         String bname;
  12.         String b1 = "book1";
  13.         String b2 = "book2";
  14.         String b3 = "book3";
  15.         String b4 = "book4";
  16.         String b5 = "book5";
  17.         String b6 = "book6";
  18.  
  19.         String user = "lamya";
  20.         String ID;
  21.         String pass = "123456";
  22.         int passw = 123456;
  23.         char gh = 'r';
  24.        
  25.         // while(gh!='0')
  26.         do {
  27.             System.out.println("HELLOW, you are welcome to the online-book store:");
  28.             System.out.println("Enter the number beside each option to proceed:");
  29.  
  30.             System.out.println(" 1:  See the list of new books\n 2: Borrow a Books\n 3: Return a Books\n 4: Show Details about the Books \n 5: Administrator only \n 0: To exit the program");
  31.             option = TextIO.getInt();
  32.  
  33.             if (option == 1) {
  34.                 System.out.println("SEE THE LIST OF NEW BOOKS:");
  35.                 System.out.println("Books in Store are:");
  36.                 System.out.println(" •  Book 1\n •  Book 2\n •  Book 3\n •  Book 4\n •     Book 5\n •  Book 6");
  37.             } else if (option == 2) {
  38.  
  39.                 // System.out.println("BORROW A BOOK:");
  40.                 System.out.println("Enter book name:");
  41.                 bname = TextIO.getlnString();
  42.  
  43.                 if (bname.contentEquals(b1) || bname.contentEquals(b2) || bname.contentEquals(b3) || bname.contentEquals(b4) || bname.contentEquals(b5) || bname.contentEquals(b6))
  44.                     System.out.println("The book is available enter 'p' to process ");
  45.                 else
  46.                     System.out.println("Sorry but the book is not available ");
  47.  
  48.             } else if (option == 3) {
  49.                 System.out.println("RETURN A BOOK");
  50.                 System.out.println("Enter book name:");
  51.                 bname = TextIO.getlnString();
  52.                 System.out.println("Enter user name:");
  53.                 user = TextIO.getlnString();
  54.                 System.out.println("Enter ID number:");
  55.                 ID = TextIO.getlnString();
  56.                 System.out.println("Thanks and do come again!");
  57.             } else if (option == 4) {
  58.                 // Title, Author1, Author2, Publisher, ISBN, Edition and
  59.                 // Publication date
  60.                 System.out.println("SHOW DETAILS ABOUT THE BOOK");
  61.  
  62.                 System.out.println("Enter Book Name:");
  63.                 bname = TextIO.getlnString();
  64.  
  65.                 if (bname.contentEquals("book1")) {
  66.                     System.out.print("book 1 is a book about ..... the author is ..");
  67.                 } else if (bname.contentEquals("book2")) {
  68.                     System.out.print("book 2 is a book about ..... the author is ..");
  69.                 } else if (bname.contentEquals("book3")) {
  70.                     System.out.print("book 3 is a book about ..... the author is ..");
  71.                 } else if (bname.contentEquals("book4")) {
  72.                     System.out.print("book 4 is a book about ..... the author is ..");
  73.                 } else if (bname.contentEquals("book5")) {
  74.                     System.out.print("book 5 is a book about ..... the author is ..");
  75.                 } else if (bname.contentEquals("book6")) {
  76.                     System.out.print("book 6 is a book about ..... the author is ..");
  77.                 } else {
  78.                     System.out.print("this book is bot available in the store");
  79.                 }
  80.             } else if (option == 5) {
  81.                 System.out.println("ADMINISTRATOR ONLY (check details of the Book Store)");
  82.                 System.out.println("enter you user name:");
  83.                 user = TextIO.getlnString();
  84.  
  85.                 System.out.println("enter password:");
  86.                 passw = TextIO.getInt();
  87.                 // pass=TextIO.getlnString();
  88.                 // if ((user.contentEquals("lamya")&&
  89.                 // pass.contentEquals("123456"))|(user.contentEquals("noura")&&pass.contentEquals("09876"))|(user.contentEquals("lama")&&pass.contentEquals("13579")))
  90.                 if ((user.contentEquals("lamya") && passw == 123456)) {
  91.                     System.out.println("this is a list if borrowed books:\n book1\n book2\n book5");
  92.                     System.out.println("the books that are available :\n book3\n book4 ");
  93.                     System.out.print("this is a list of the users:  lamya\n  noura\n  lama");
  94.                 } else
  95.                     System.out.print("you do not have a valid account ");
  96.             } else {
  97.                 System.out.println("You did not enter the valid choice");
  98.             }
  99.             // System.exit(0);
  100.             // gh++;
  101.             System.out.println("To go back press 'G', To exit press '0'");
  102.             gh = TextIO.getChar();
  103.            
  104.         } while (gh != 'e');
  105.  
  106.     }
  107.  
  108. }
  109.  
  110. /**
  111.  * Class to handle standard input functionalities
  112.  */
  113. class TextIO {
  114.     /**
  115.      * static (one) instance of a bufferedreader
  116.      */
  117.     private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  118.  
  119.     /**
  120.      * Reads a string from standard input
  121.      *
  122.      * @return string from standard input
  123.      */
  124.     public static String getlnString() {
  125.         try {
  126.             return br.readLine();
  127.         } catch (Exception e) {
  128.             return "";
  129.         }
  130.     }
  131.  
  132.     /**
  133.      * Reads a char from standard input
  134.      *
  135.      * @return char from standard input
  136.      */
  137.     public static char getChar() {
  138.         return getlnString().charAt(0);
  139.     }
  140.  
  141.     /**
  142.      * Reads a integer from standard input
  143.      *
  144.      * @return int from standard input
  145.      */
  146.     public static int getInt() {
  147.         while (true)
  148.             try {
  149.                 return Integer.parseInt(getlnString());
  150.             } catch (Exception e) {
  151.                 // return 0;
  152.             }
  153.     }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement