Advertisement
Guest User

Untitled

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