Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
bookstore (shopping,user,personal,borrowing)
package bookstore; import java.util.*; public class Bookstore { public static void main(String[] args) { Scanner input = new Scanner(System.in); ArrayList<String> bookList= new ArrayList<>(); bookList.add("THE ART OF THINKING CLEARLY"); bookList.add(" THE IS ALSO STAR"); bookList.add("ORIGIN"); bookList.add("AN UNQUIT MIND"); bookList.add("THE SECRET HISTORY OF THE WORLD"); System.out.println( bookList); System.out.println("Please enter the desired book "); String wantedBook= input.nextLine(); wantedBook.toUpperCase(); do{ if(bookList.contains(wantedBook)){ if(Shopping.PurchasedBook.contains(wantedBook)) System.out.println("Sorry the desierd book purchased"); else if(Borrowing.borrowededBook.contains(wantedBook)) System.out.println("Sorry the desierd book borrowed"); } else System.out.println("Sorry we can't find the book , enter another book"); wantedBook= input.next(); wantedBook.toUpperCase(); } while(bookList.contains(wantedBook)==false); System.out.println("Please enter 1 to purchase the book , or 2 to borrow the book"); int x=input.nextInt(); System.out.println("Please enter your name and id" ); String customer= input.next(); int id=input.nextInt(); switch(x){ case 1: Shopping(wantedBook,1000,customer,id); break; case 2: break; default:System.out.println( "Sorry invalid input"); } } } class Shopping{ private String bookName; private int bookId; private String customerName; private int customerId; private int totalPurchasedBooks; static ArrayList<String> PurchasedBook= new ArrayList<>(); Shopping(){ ++totalPurchasedBooks; } Shopping(String bookn,int bookid, String customern,int customerid){ bookName= bookn; bookId=bookid; customerName=customern; customerId=customerid; ++totalPurchasedBooks; } public String getBookName (){ return bookName; } public int getBookId (){ return bookId; } public String getCustomerName (){ return customerName; } public int getCustomerId (){ return customerId; } //public } class Borrowing extends Shopping { private Date borrowingDate; private Date returningDate; private int borrowingDuration; public double borrowingPrice; public User book; public User u_ser; static ArrayList<String> borrowededBook= new ArrayList<>(); public Borrowing() { } public Borrowing(Date borrowingDate, Date returningDate, int borrowingDuration, double borrowingPrice, User book, User u_ser) { this.borrowingDate = borrowingDate; this.returningDate = returningDate; this.borrowingDuration = borrowingDuration; this.borrowingPrice = borrowingPrice; this.book = book; this.u_ser = u_ser; } public Date getBorrowingDate() { return borrowingDate; } public Date getReturningDate() { return returningDate; } public int getBorrowingDuration() { return borrowingDuration; } public double getBorrowingPrice() { return borrowingPrice; } public void setBorrowingDate(Date borrowingDate) { this.borrowingDate = borrowingDate; } public void setReturningDate(Date returningDate) { this.returningDate = returningDate; } public void setBorrowingDuration(int borrowingDuration) { this.borrowingDuration = borrowingDuration; } public void setBorrowingPrice(double borrowingPrice) { this.borrowingPrice = borrowingPrice; } } abstract class Personal { Scanner input = new Scanner(System.in); static int ID; static String name, Email; Personal(){}; Personal(int ID,String name,String Email){ Personal.ID=ID; Personal.Email=Email; Personal.name=name;} public abstract void PrintInfo(int Id, String name, String Email); } class User extends Personal { Scanner Input = new Scanner(System.in); static int tnob=0; static String bookname; static String address, order; public static User[] BorrowedBooks = new User [100]; public static ArrayList<String> FavList= new ArrayList<>(); User(){}; User(int ID, String name, String Email, String address){ User.ID=ID; User.Email=Email; User.name=name; User.address=address;} User(String bookname){User.bookname=bookname;} public String getOrder(){return order;} public void setOrder(String order){User.order=order;} public String getAddress(){return address;} public void setAddress(String address){User.address=address;} //public String setBookname(String bookname){} @Override public void PrintInfo(int ID, String name, String email){ System.out.println("name :"+name+"\n"+name +"'s ID: "+ID+ "\nEmail:"+Email); } public void setBorrowedBooks(){ System.out.println("enter the name of the book"); bookname= Input.nextLine(); for(int i=0;i<tnob;i++){ BorrowedBooks[i]=new User(bookname); tnob++;} } public static void getBorrowedBooks(String x){ for (int i=0;i<=tnob;i++) System.out.println("book name "+ x); }}
run
|
edit
|
history
|
help
0
Firstproject
Equal_HashCode_TEST --- imporatnt concept about hashing
ElaineBrown**
// Java Coding Challenge - 07: Print out Fibonacci number 0 - 1000
[Java] Coding - Reverse CODE-StringBuilder
Using Recursion reverse the Line
Trapping Rain Water
Desvio Padrão - LPI
3e
Validate mobile number