Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class project_lamia {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int option;
- String bname;
- String b1="book1";
- String b2="book2";
- String b3="book3";
- String b4="book4";
- String b5="book5";
- String b6="book6";
- String user="lamya";
- String ID;
- String pass="123456";
- int passw=123456;
- char gh='r';
- do
- //while(gh!='0')
- {
- System.out.println("HELLOW, you are welcome to the online-book store:");
- System.out.println("Enter the number beside each option to proceed:");
- 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");
- option=TextIO.getInt();
- if (option==1)
- {
- System.out.println("SEE THE LIST OF NEW BOOKS:");
- System.out.println("Books in Store are:");
- System.out.println(" • Book 1\n • Book 2\n • Book 3\n • Book 4\n • Book 5\n • Book 6");
- }
- else if (option==2)
- {
- //System.out.println("BORROW A BOOK:");
- System.out.println("Enter book name:");
- bname=TextIO.getlnString();
- if (bname.contentEquals(b1)|| bname.contentEquals(b2)||bname.contentEquals(b3)||bname.contentEquals(b4)||bname.contentEquals(b5)||bname.contentEquals(b6))
- System.out.println("The book is available enter 'p' to process ");
- else
- System.out.println("Sorry but the book is not available ");
- }
- else if (option==3)
- {
- System.out.println("RETURN A BOOK");
- System.out.println("Enter book name:");
- bname=TextIO.getlnString();
- System.out.println("Enter user name:");
- user=TextIO.getlnString();
- System.out.println("Enter ID number:");
- ID=TextIO.getlnString();
- System.out.println("Thanks and do come again!");
- }
- else if (option==4)
- {
- System.out.println("SHOW DETAILS ABOUT THE BOOK");
- System.out.println("Enter Book Name:");
- bname=TextIO.getlnString();
- if (bname.contentEquals("book1"))
- {
- System.out.print("book 1 is a book about ..... the author is ..");
- }
- else if (bname.contentEquals("book2"))
- {
- System.out.print("book 2 is a book about ..... the author is ..");
- }
- else if (bname.contentEquals("book3"))
- {
- System.out.print("book 3 is a book about ..... the author is ..");
- }
- else if (bname.contentEquals("book4"))
- {
- System.out.print("book 4 is a book about ..... the author is ..");
- }
- else if (bname.contentEquals("book5"))
- {
- System.out.print("book 5 is a book about ..... the author is ..");
- }
- else if (bname.contentEquals("book6"))
- {
- System.out.print("book 6 is a book about ..... the author is ..");
- }
- else
- {
- System.out.print("this book is bot available in the store");
- }
- }
- // Title, Author1, Author2, Publisher, ISBN, Edition and
- // Publication date
- else if (option==5)
- {
- System.out.println("ADMINISTRATOR ONLY (check details of the Book Store)");
- System.out.println("enter you user name:");
- user=TextIO.getlnString();
- System.out.println("enter password:");
- passw=TextIO.getInt();
- //pass=TextIO.getlnString();
- if ((user.contentEquals("lamya")&& passw==123456))
- //if ((user.contentEquals("lamya")&& pass.contentEquals("123456"))|(user.contentEquals("noura")&&pass.contentEquals("09876"))|(user.contentEquals("lama")&&pass.contentEquals("13579")))
- {
- System.out.println("this is a list if borrowed books:\n book1\n book2\n book5");
- System.out.println("the books that are available :\n book3\n book4 ");
- System.out.print("this is a list of the users: lamya\n noura\n lama");
- }
- else
- System.out.print("you do not have a valid account ");
- }
- else
- System.out.println("You did not enter the valid choice");
- //System.exit(0);
- //gh++;
- System.out.println("To go back press 'G', To exit press '0'");
- gh=TextIO.getChar();
- }
- while (gh!='e');
- }
- }
- /**
- * Class to handle standard input functionalities
- */
- class TextIO {
- /**
- * static (one) instance of a bufferedreader
- */
- private static BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
- /**
- * Reads a string from standard input
- *
- * @return string from standard input
- */
- public static String getlnString() {
- try {
- return br.readLine();
- } catch( Exception e ) {
- return "";
- }
- }
- /**
- * Reads a char from standard input
- *
- * @return char from standard input
- */
- public static char getChar() {
- return getlnString().charAt(0);
- }
- /**
- * Reads a integer from standard input
- *
- * @return int from standard input
- */
- public static int getInt() {
- while( true )
- try {
- return Integer.parseInt( getlnString() );
- } catch( Exception e ) {
- // return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement