Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.92 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.             }
  38.  
  39.             else if (option == 2) {
  40.  
  41.                 // System.out.println("BORROW A BOOK:");
  42.                 System.out.println("Enter book name:");
  43.                 bname = TextIO.getlnString();
  44.  
  45.                 if (bname.contentEquals(b1) || bname.contentEquals(b2) || bname.contentEquals(b3) || bname.contentEquals(b4) || bname.contentEquals(b5) || bname.contentEquals(b6))
  46.  
  47.                     System.out.println("The book is available enter 'p' to process ");
  48.  
  49.                 else
  50.  
  51.                     System.out.println("Sorry but the book is not available ");
  52.  
  53.             }
  54.  
  55.             else if (option == 3) {
  56.                 System.out.println("RETURN A BOOK");
  57.                 System.out.println("Enter book name:");
  58.                 bname = TextIO.getlnString();
  59.                 System.out.println("Enter user name:");
  60.                 user = TextIO.getlnString();
  61.                 System.out.println("Enter ID number:");
  62.                 ID = TextIO.getlnString();
  63.                 System.out.println("Thanks and do come again!");
  64.             }
  65.  
  66.             else if (option == 4) {
  67.                 System.out.println("SHOW DETAILS ABOUT THE BOOK");
  68.  
  69.                 System.out.println("Enter Book Name:");
  70.                 bname = TextIO.getlnString();
  71.  
  72.                 if (bname.contentEquals("book1")) {
  73.                     System.out.print("book 1 is a book about ..... the author is ..");
  74.                 } else if (bname.contentEquals("book2")) {
  75.                     System.out.print("book 2 is a book about ..... the author is ..");
  76.                 } else if (bname.contentEquals("book3")) {
  77.                     System.out.print("book 3 is a book about ..... the author is ..");
  78.                 } else if (bname.contentEquals("book4")) {
  79.                     System.out.print("book 4 is a book about ..... the author is ..");
  80.                 } else if (bname.contentEquals("book5")) {
  81.                     System.out.print("book 5 is a book about ..... the author is ..");
  82.                 } else if (bname.contentEquals("book6")) {
  83.                     System.out.print("book 6 is a book about ..... the author is ..");
  84.                 } else {
  85.                     System.out.print("this book is bot available in the store");
  86.                 }
  87.             }
  88.             // Title, Author1, Author2, Publisher, ISBN, Edition and
  89.             // Publication date
  90.  
  91.             else if (option == 5) {
  92.                 System.out.println("ADMINISTRATOR ONLY (check details of the Book Store)");
  93.                 System.out.println("enter you user name:");
  94.                 user = TextIO.getlnString();
  95.  
  96.                 System.out.println("enter password:");
  97.                 passw = TextIO.getInt();
  98.                 // pass=TextIO.getlnString();
  99.                 if ((user.contentEquals("lamya") && passw == 123456))
  100.  
  101.                 // if ((user.contentEquals("lamya")&&
  102.                 // pass.contentEquals("123456"))|(user.contentEquals("noura")&&pass.contentEquals("09876"))|(user.contentEquals("lama")&&pass.contentEquals("13579")))
  103.                 {
  104.                     System.out.println("this is a list if borrowed books:\n book1\n book2\n book5");
  105.                     System.out.println("the books that are available :\n book3\n book4 ");
  106.                     System.out.print("this is a list of the users:  lamya\n  noura\n  lama");
  107.                 } else
  108.                     System.out.print("you do not have a valid account ");
  109.             }
  110.  
  111.             else
  112.                 System.out.println("You did not enter the valid choice");
  113.  
  114.             // System.exit(0);
  115.             // gh++;
  116.             System.out.println("To go back press 'G', To exit press '0'");
  117.             gh = TextIO.getChar();
  118.  
  119.         } while (gh != 'e');
  120.  
  121.     }
  122.  
  123. }
  124.  
  125. /**
  126.  * Class to handle standard input functionalities
  127.  */
  128. class TextIO {
  129.     /**
  130.      * static (one) instance of a bufferedreader
  131.      */
  132.     private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  133.  
  134.     /**
  135.      * Reads a string from standard input
  136.      *
  137.      * @return string from standard input
  138.      */
  139.     public static String getlnString() {
  140.         try {
  141.             return br.readLine();
  142.         } catch (Exception e) {
  143.             return "";
  144.         }
  145.     }
  146.  
  147.     /**
  148.      * Reads a char from standard input
  149.      *
  150.      * @return char from standard input
  151.      */
  152.     public static char getChar() {
  153.         return getlnString().charAt(0);
  154.     }
  155.  
  156.     /**
  157.      * Reads a integer from standard input
  158.      *
  159.      * @return int from standard input
  160.      */
  161.     public static int getInt() {
  162.         while (true)
  163.             try {
  164.                 return Integer.parseInt(getlnString());
  165.             } catch (Exception e) {
  166.                 // return 0;
  167.             }
  168.     }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement