Results 1 to 5 of 5
  1. #1
    sheckoo is offline Member
    Join Date
    Oct 2008
    Location
    Egypt
    Posts
    26
    Rep Power
    0

    Default my project problem??help please

    now this my project code but after i finished it the doctor told us that she wants it but by using OOP without using statics instances or methods can any body tell me how to do it and give me your mind about this code ingeneral
    ......................
    Java Code:
    import java.io.*;
    
    public class booksmanagement {
    	private static String inDataBook;
    	private static int searchResultCounterTitle;	
    	private static int booksInformationCounter ;
    	private static int searchResultCounterAuthorandCategory;	
    	
    	static int IS;
    	private static String [] BooksInformation = new String[100];
    	
    	public booksmanagement(){
    	booksInformationCounter=0;
    	for(int x=0; x<BooksInformation.length;x++)
    		BooksInformation[x]="";
    	
    		
    	
    	}
    	
    	
    	//method to load from the file into the array 
    	
    	public static String[] LoadBooksInFormation() throws Exception{
    	try{
    		BufferedReader in=new BufferedReader(new FileReader("C:\\Users\\VooDoo\\Desktop\\LibrarySystem\\books.txt"));
    		
    		String read;
    	
    		while((read = in.readLine()) != null && booksInformationCounter<BooksInformation.length){
    	
    			if(read.equals(""))
    			read=null;
    		 
    			else
    			{	
    			BooksInformation[booksInformationCounter]=read.toLowerCase();
    	String[] JustForEx  = read.split(",");
    
    	if(JustForEx.length>8)
    		throw new IOException();
    	
    	if(JustForEx[0].equalsIgnoreCase("")||JustForEx[1].equalsIgnoreCase("")||JustForEx[2].equalsIgnoreCase("")||
    			JustForEx[3].equalsIgnoreCase("")||JustForEx[4].equalsIgnoreCase("")||JustForEx[5].equalsIgnoreCase("")||
    			JustForEx[6].equalsIgnoreCase("")||JustForEx[7].equalsIgnoreCase(""))
    		throw new IOException();
    	
    	if(!JustForEx[3].toLowerCase().equals(JustForEx[3].toUpperCase())||!JustForEx[5].toLowerCase().equals(JustForEx[5].toUpperCase())||!JustForEx[6].toLowerCase().equals(JustForEx[6].toUpperCase()))
    		throw new IOException();
    	
    				booksInformationCounter++;
    		}
    		}
    		in.close();
    	}
    	catch(IOException e){
    		System.out.println("Error \n cannot load from Books file");
    		System.exit(0);
    		
    	}
    		return BooksInformation;
    	}
    	//method to  get the number of elements which is not empety
    	public static int getDataSize(){
    		return booksInformationCounter ;
    	}
    	
    // method to take data from the user and write it in the array and the file
    	public static String[] TakeBooksInformationfromUser() throws IOException{
    	try{String Continue="y";
    		
    	while(Continue.equalsIgnoreCase("y")||Continue.equalsIgnoreCase("yes"))
    		{
    		String Check="";
    		BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
    		inDataBook="";
    					
    			System.out.println("Enter the book`s title; ");
    		Check=in.readLine();
    			if(Check.equals(""))
    			throw new IOException();
    			inDataBook=Check;
    			
    			System.out.println("Enter the book`s author; ");
    			Check=in.readLine();
    			if(Check.equals(""))
    				throw new IOException();
    			inDataBook+=","+Check;
    			
    			System.out.println("Enter the book`s publisher; ");
    			Check=in.readLine();
    			if(Check.equals(""))
    				throw new IOException();
    				inDataBook+=","+Check;
    			
    			System.out.println("Enter the book`s ISBN; ");
    			Check=in.readLine();
    			if(Check.equals(""))
    				throw new IOException();
    			if(!Check.toLowerCase().equals(Check.toUpperCase()))
    				throw new IOException();
    			inDataBook+=","+Check;
    			
    			System.out.println("Enter the date of publesher for the book; ");
    			Check=in.readLine();
    			if(Check.equals(""))
    				throw new IOException();
    				inDataBook+=","+Check;
    			
    			System.out.println("Enter the number of the copies of the book ; ");
    			Check=in.readLine();
    			if(Check.equals(""))
    				throw new IOException();
    			if(!Check.toLowerCase().equals(Check.toUpperCase()))
    				throw new IOException();
    			String NC=Check;	
    			inDataBook+=","+Check;
    			
    			System.out.println("Enter the number of the avilable copies of the book; ");
    			Check=in.readLine();
    			if(Check.equals(""))
    				throw new IOException();
    			if(!Check.toLowerCase().equals(Check.toUpperCase()))
    				throw new IOException();
    			if(Integer.parseInt(Check)>Integer.parseInt(NC))
    				throw new IOException();
    			inDataBook+=","+Check;
    
    			System.out.println("Enter the book`s category; ");
    			Check=in.readLine();
    			if(Check.equals(""))
    				throw new IOException();
    				inDataBook+=","+Check;
     System.out.println(inDataBook);
    			
    BooksInformation[booksInformationCounter]=inDataBook.toLowerCase();
    			
    	System.out.println("if you want to enter another book`s information press y or yes  ");
    		Continue=in.readLine();
    			booksInformationCounter++;
    		}}
    	catch(IOException e){
    		System.out.println("Error \n  Wrong information ");
    	}
    			
    		return BooksInformation;
    	}
    	
    //method to search for books by the title of the book
    public static String [] SearchWithTitle(String title)
    {
    	String [] SearchResultT=new String[BooksInformation.length];
    	SearchResultT[0]="book is not found";
    	
    	for(int o=1; o<SearchResultT.length; o++)
    		SearchResultT[o]="";
      
    	int hh;
    	searchResultCounterTitle=0;
    	
     
      
       for( hh=0 ; hh < booksInformationCounter ;hh++ ){
    	   int f=0;
    	   int k=0;
    		
    	   int z=1;
    		String s1="";
    	    String s2="";
    		String s3="";
    	String [] search=BooksInformation[hh].split(",");
       
    	   
    	while( f<title.length() && k<search[0].length()){
    		
     			s1= Character.toString(title.toLowerCase().charAt(f)) ;
    			s2=Character.toString(search[0].charAt(k));
    			
    		if	(s1.equals(s2))
    		{
    			f++;
    			k++;
    			s3 +=s2;
    		}		
    		else{
    		   k=z;
    			f=0;
    			
    		s3="";
    		z++;
    		}
    		if(title.toLowerCase().equals(s3)){
    
    		     SearchResultT[searchResultCounterTitle]=BooksInformation[hh];
    			
    		    searchResultCounterTitle++;
    
    			}
    				
    	}
    		
    
    	
       }
    	
    		return SearchResultT;
    	
    	}
    	//method to get the Search result array size
    public static int getSearchTiltlarraySize()
    {int gg=searchResultCounterTitle+1;
    	return gg;
    }
    	//method to search by the ISBN number
       public static String  SearchWithISBN(String ISBN)
       {   IS=-1;   
    	  String  SearchResultI="";
    	  SearchResultI="book is not found";
    	 int hh;
    
    	for( hh=0 ; hh<booksInformationCounter;hh++ ){	
    	   
    	String [] search=BooksInformation[hh].split(",");
    
    	if(ISBN.equals(search[3])){
    	IS=hh;
    	 SearchResultI=BooksInformation[hh];
    break;
     }
     }
    	
    		return SearchResultI;
    	
    	}
    	//method to get the Search result array size
    
    
    //method to search for books by the Author of the book
    public static String [] SearchWithAuthor(String author)
    {
    	String [] SearchResultA=new String[BooksInformation.length];
       
    	for(int i=0;i<SearchResultA.length;i++)
    	   SearchResultA[i]="";
    	
    	SearchResultA[0]="book is not found";
        
    	 searchResultCounterAuthorandCategory=0;
        int hh;
    
    	for( hh=0 ; hh<booksInformationCounter;hh++ ){
    	String [] search=BooksInformation[hh].split(",");
    
    	if(author.equals(search[1])){
    	
    	  SearchResultA[searchResultCounterAuthorandCategory]=BooksInformation[hh];
    
    	searchResultCounterAuthorandCategory++;	
        }
    	}
    	if(searchResultCounterAuthorandCategory==0)
    		searchResultCounterAuthorandCategory=1;
    
    		return SearchResultA;
    	
    	}
    	
    	//method to search for books by the Category of the book
    	public static String [] SearchWithCategory(String category)
    	{
    		String [] SearchResultC=new String[BooksInformation.length];
    	   
    	
    		searchResultCounterAuthorandCategory=0;
    		for(int i=0;i<SearchResultC.length;i++)
    			   SearchResultC[i]="";
    		SearchResultC[0]="book is not found";
    			
    	
    	    int hh;
    
    		for( hh=0 ; hh<booksInformationCounter;hh++ ){
    		String [] search=BooksInformation[hh].split(",");
    
         if(category.equals(search[7])){
            
            	  SearchResultC[searchResultCounterAuthorandCategory]=BooksInformation[hh];
            
            	  searchResultCounterAuthorandCategory++;
            }
    		}
    		if(searchResultCounterAuthorandCategory==0)
    			searchResultCounterAuthorandCategory=1;
    			return SearchResultC;
    		
    		}
    	
    	public static int getsearchResultCounterAuthorandCategory()
    	{
    		return searchResultCounterAuthorandCategory;
    	}
    
    	
    	
    	public static void Borrow(String ISBN ,int t){
    	booksmanagement.SearchWithISBN(ISBN);
    	if( IS ==-1)
    	System.out.println(" Wrong ISBN");
    	else
    	{
    		String [] ff=BooksInformation[IS].split(",");
    		
    		String totalAVilible=String.valueOf(Integer.parseInt(ff[6])-t);
    	ff[6]=totalAVilible;
    	
    	String totalbook=ff[0]+","+ff[1]+","+ff[2]+","+ff[3]+","+ff[4]+","+ff[5]+","+ff[6]+","+ff[7];		
    	BooksInformation[IS]=totalbook;
    		
    	}
    	
    	
    }
    
    public static void Return(String ISBN ,int t){
    	booksmanagement.SearchWithISBN(ISBN);
    	if( IS ==-1)
    	System.out.println(" Wrong ISBN");
    	else
    	{
    		String [] ff=BooksInformation[IS].split(",");
    		
    		String totalAVilible=String.valueOf(Integer.parseInt(ff[6])+t);
    	ff[6]=totalAVilible;
    	
    	String totalbook=ff[0]+","+ff[1]+","+ff[2]+","+ff[3]+","+ff[4]+","+ff[5]+","+ff[6]+","+ff[7];		
    	BooksInformation[IS]=totalbook;
    		
    	}
    	
    	
    }		
    		// method to add new copy
    		
    	public static void AddNewCopies(String ISBN1, int NumberOfCopies){
    		
    		booksmanagement.SearchWithISBN(ISBN1);
    		if(IS==-1)
    			  System.out.println("Wrong ISBN ");
    		else{
    		
    		String [] ff=BooksInformation[IS].split(",");
    		String totalnmber=String.valueOf(Integer.parseInt(ff[5])+NumberOfCopies);
    		String totalAVilible=String.valueOf(Integer.parseInt(ff[6])+NumberOfCopies);
    	ff[5]=totalnmber;
    	ff[6]=totalAVilible;
    	
    	String totalbook=ff[0]+","+ff[1]+","+ff[2]+","+ff[3]+","+ff[4]+","+ff[5]+","+ff[6]+","+ff[7];		
    	BooksInformation[IS]=totalbook;
    		}
       
    	}
    	//method to delete a book  	
    	public static void DeleteBooks(String ISBN){
    		booksmanagement.SearchWithISBN(ISBN);
    		if(IS==-1)
    			  System.out.println("Wrong ISBN ");
    		else
    			System.arraycopy(BooksInformation, IS+1, BooksInformation, IS, booksInformationCounter-1);
    		
    	   	
    		
    	}
    		public static void RewriteBooksInformations() throws IOException{
    		int w;	
    BufferedWriter out= new BufferedWriter(new FileWriter("C:\\Users\\VooDoo\\Desktop\\LibrarySystem\\books.txt"));
    			
    String transport;
                  for(w=0;w<=booksInformationCounter;w++){
    			
                	  transport=BooksInformation[w];
                	
    			out.write(transport+"\n");
    			
                     
    			}
                  out.close();
    		}
    		
    	
    	
    	public static String[] MostPopularBooks(){
    		
    		String[] coppyOFbook=new String[booksInformationCounter];
    	  System.arraycopy(BooksInformation, 0, coppyOFbook, 0, booksInformationCounter);
    		int coppyOfbookCounter=booksInformationCounter;
    		String[] PopularBooks=new String [10];
    		String[] justC = new String[8];
    		
    	for(int p=0;p<10;p++)
    		PopularBooks[p]="";
    	
    		for(int t=0;t<8;t++)
    			justC[t]="";
    	for(int z=0;z<10;z++){	
    		justC=coppyOFbook[0].split(",");
    	double persent=(Double.parseDouble(justC[6])/Double.parseDouble(justC[5]));
    	
    	int popBook=0;
    		
    		for(int i=1;i<coppyOfbookCounter;i++){
    			justC=coppyOFbook[i].split(",");
    			
    			if(persent>(Double.parseDouble(justC[6])/Double.parseDouble(justC[5])))
    			{
    				persent=Double.parseDouble(justC[6])/Double.parseDouble(justC[5]);
    			popBook=i;
    			}
    	
    		}
    		coppyOfbookCounter--;
    		
    	PopularBooks[z]=coppyOFbook[popBook];
    	for(int x=popBook;x<coppyOfbookCounter;x++)
    		coppyOFbook[x]=coppyOFbook[x+1];
    	}
    	
    return PopularBooks;		
    	}
    
    public static String[] getArrayOfBooks(){
    	return BooksInformation;
    }
    }
    
    
    .............................
    
    import java.io.*;
    import java.text.*;
    import java.util.*;
    public class Member {
    	
    	private static int memberInformationCounter ;
         private static int borrowedBooksInformationCounter;
         private static int LatedBooksCounter;
     	
         private static String inDatamember;
    	private static String inDataBorrowed;
    	private static String [] MemberInformation = new String[100];
    	private static String [] borrowedBooksInformation=new String[1000];
    	private static String[][] MemberandNumberofBorrowedBooks=new String[100][2];
    	
    	public Member(){
    		LatedBooksCounter=0;
    		borrowedBooksInformationCounter=0;
    		memberInformationCounter=0;
    		for(int x=0; x<MemberInformation.length;x++)
    			MemberInformation[x]="";
    		for(int x=0; x<borrowedBooksInformation.length;x++)
    			borrowedBooksInformation[x]="";
    		for(int x=0; x<100;x++)
    			{for(int j=0; j <2;j++){
    				if(j==0)
    			MemberandNumberofBorrowedBooks[x][j]="";
    			    if(j==1)
    			    	MemberandNumberofBorrowedBooks[x][j]="0";
    			}}
    		}
    
    	//method to load from the file into the array 
    	
    	public static String[] LoadMemberInFormation() throws IOException{
    	try{
    		BufferedReader in=new BufferedReader(new FileReader("C:\\Users\\VooDoo\\Desktop\\LibrarySystem\\members.txt"));
    		
    		String read;
    		while((read = in.readLine()) != null && memberInformationCounter<MemberInformation.length){
    				if(read.equals(""))
    					read=null;
    				else{
    			   MemberInformation[memberInformationCounter]=read.toLowerCase();
    			   String[] JustForEx  = read.split(",");
    
    				if(JustForEx.length>8)
    					throw new IOException();
    				
    				if(JustForEx[0].equalsIgnoreCase("")||JustForEx[1].equalsIgnoreCase("")||JustForEx[2].equalsIgnoreCase("")||
    						JustForEx[3].equalsIgnoreCase("")||JustForEx[4].equalsIgnoreCase("")||JustForEx[5].equalsIgnoreCase("")||
    						JustForEx[6].equalsIgnoreCase("")||JustForEx[7].equalsIgnoreCase(""))
    					throw new IOException();
    				
    				if(!JustForEx[5].toLowerCase().equals(JustForEx[5].toUpperCase())||!JustForEx[0].toLowerCase().equals(JustForEx[0].toUpperCase())||!JustForEx[6].toLowerCase().equals(JustForEx[6].toUpperCase()))
    					throw new IOException();
    				
    			memberInformationCounter++;
    				}
    		}
    		in.close();
    	}
    	catch(IOException e){
    		System.out.println("Error\n cannot load from Members file");
    		System.exit(0);
    	}
    		return MemberInformation;
    	}
    
    public static String[] getMemberArray(){
    	return MemberInformation;
    }
    	//method to  get the number of elements which is not empety
    	public static int getDataSizeofMemberinformation(){
    		return memberInformationCounter ;
    	}
    	//method to load from the file into the array 
    	
    	public static String[] LoadBorrowedBooksInFormation() throws IOException{
    	try{
    		BufferedReader in=new BufferedReader(new FileReader("C:\\Users\\VooDoo\\Desktop\\LibrarySystem\\borrowedbooks.txt"));
    		
    		String read;
    		while((read = in.readLine()) != null && borrowedBooksInformationCounter<borrowedBooksInformation.length){
    		if(read.equals(""))
    			read=null;
    		else{
    			   borrowedBooksInformation[borrowedBooksInformationCounter]=read.toLowerCase();
    			   String[] JustForEx  = read.split(",");
    
    				if(JustForEx.length>5)
    					throw new IOException();
    				
    				if(JustForEx[0].equalsIgnoreCase("")||JustForEx[1].equalsIgnoreCase("")||JustForEx[2].equalsIgnoreCase("")||
    						JustForEx[3].equalsIgnoreCase(""))
    					throw new IOException();
    				
    				if(!JustForEx[0].toLowerCase().equals(JustForEx[0].toUpperCase())||!JustForEx[1].toLowerCase().equals(JustForEx[1].toUpperCase()))
    					throw new IOException();
    				
    			borrowedBooksInformationCounter++;
    		}
    		}
    		in.close();
    	}
    	catch(IOException e){
    		System.out.println("error \n cannot load from  Borrowed Books file");
    		System.exit(0);
    		
    	}
    		return borrowedBooksInformation;
    	}
    
    	// method to take data from the user and write it in the array and the file
    	public static String[] TakeMemberInformationfromUser() throws IOException{
    	
    	try{	String Continue="y";
    	while(Continue.equalsIgnoreCase("y")||Continue.equalsIgnoreCase("yes"))
    	{
    		String Check="";
    
    		BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
    		inDatamember="";
    		
    		System.out.println("Enter the Member`s ID; ");
    	Check=in.readLine();
    		if(Check.equals(""))
    		throw new IOException();
    		if(!Check.toLowerCase().equals(Check.toUpperCase()))
    			throw new IOException();
    		inDatamember=Check;
    		
    		System.out.println("Enter the Member`s name; ");
    		Check=in.readLine();
    		if(Check.equals(""))
    			throw new IOException();
    		inDatamember+=","+Check;
    		
    		System.out.println("Enter the Member`s address; ");
    		Check=in.readLine();
    		if(Check.equals(""))
    			throw new IOException();
    		inDatamember+=","+Check;
    		
    		System.out.println("Enter the Member`s street; ");
    		Check=in.readLine();
    		if(Check.equals(""))
    			throw new IOException();
    		inDatamember+=","+Check;
    		
    		System.out.println("Enter the Member`s city; ");
    		Check=in.readLine();
    		if(Check.equals(""))
    			throw new IOException();
    		inDatamember+=","+Check;
    		
    		System.out.println("Enter the Member`s phone number ; ");
    		Check=in.readLine();
    		if(Check.equals(""))
    			throw new IOException();
    		if(!Check.toLowerCase().equals(Check.toUpperCase()))
    			throw new IOException();
    		inDatamember+=","+Check;
    		
    		System.out.println("Enter the Member`s age; ");
    		Check=in.readLine();
    		if(Check.equals(""))
    			throw new IOException();
    		if(!Check.toLowerCase().equals(Check.toUpperCase()))
    			throw new IOException();
    		inDatamember+=","+Check;
    
    		System.out.println("Enter the Member`s emailaddress ; ");
    		Check=in.readLine();
    		if(Check.equals(""))
    			throw new IOException();
    		inDatamember+=","+Check;
    
    		System.out.println(inDatamember);
    
    		
    			MemberInformation[memberInformationCounter]=inDatamember.toLowerCase();
    	System.out.println("if you want to add another member please Enter y or yes");		
    			Continue=in.readLine();
    			memberInformationCounter++;
    	}}
    	catch(IOException e){
    		System.out.println("Error \n Wrong information");
    	}
    			
    		return MemberInformation;
    	}
    	//method to copy the members id form the member array to the member and number of borrowed books array
    	public static void CopyID(){
    		String[] coppyid=new String[100];
    		for(int v=0; v < memberInformationCounter;v++ ){
    			coppyid=MemberInformation[v].split(",");
    			MemberandNumberofBorrowedBooks[v][0]=coppyid[0];
    		}
    		
    	}
    // method to manage the borrowing operations
    	public static void BorrowedBooks() throws IOException{
    try{String Continue="y";
    int vv=0;
    while(true)
    	{
    		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    	if(vv>0)
    	{
    		System.out.println("if you want to do another Borrowing proces press y or yes  ");
    		Continue=in.readLine();
    		if(!Continue.equalsIgnoreCase("y")||!Continue.equalsIgnoreCase("yes"))
                 break;	
    	}
    		String Check="";
    System.out.println("Enter the ISBN");
    Check=in.readLine();
    if(Check.equals(""))
    	throw new IOException("Wrong Information");
    if(!Check.toLowerCase().equals(Check.toUpperCase()))
    	throw new IOException("Wrong Information");
    String ISBN=Check;
    
    System.out.println("Enter the ID");
    Check=in.readLine();
    if(Check.equals(""))
    	throw new IOException("Wrong Information");
    if(!Check.toLowerCase().equals(Check.toUpperCase()))
    	throw new IOException("Wrong Information");
    String ID=Check;
    		
    System.out.println("Enter the date issued like this format dd/mm/yy ");
    Check=in.readLine();
    if(Check.equals(""))
    	throw new IOException("Wrong Information");
    if(!Check.toLowerCase().equals(Check.toUpperCase()))
    	throw new IOException("Wrong Information");
    String dateissued=Check;
    
    System.out.println("Enter the date due to return like this format dd/mm/yy ");
    Check=in.readLine();
    if(Check.equals(""))
    	throw new IOException("Wrong Information");
    if(!Check.toLowerCase().equals(Check.toUpperCase()))
    	throw new IOException("Wrong Information");
    String dateofreturn=Check;
    
    boolean found=false;
    int cc = 0;
    		booksmanagement.Borrow(ISBN, 1);
    if(booksmanagement.IS==-1)
    	throw new IOException("Wrong Information");
    
    		if(booksmanagement.IS !=-1){		
    	  for( int bb=0; bb < memberInformationCounter ; bb++)
    	  {
    		if(ID.equals(MemberandNumberofBorrowedBooks[bb][0]))
    		{
    			cc =Integer.parseInt(MemberandNumberofBorrowedBooks[bb][1]);
    	cc++;
    	if(cc>3)
    		throw new IOException(" Member cannot borrow more than 3 books");
    			
    		MemberandNumberofBorrowedBooks[bb][1]=String.valueOf(cc);
    	found=true;
    		break;
    		}
    		else{
    			if(bb==memberInformationCounter-1)
    				System.out.println("Wrong ID");
    			
    			
    			}
    	  }if(found){
    			inDataBorrowed=ISBN+","+ID+","+dateissued+","+dateofreturn;
    			
    			borrowedBooksInformation[borrowedBooksInformationCounter]=inDataBorrowed;
    				
    			borrowedBooksInformationCounter++;
    	  }
    	  }
    		vv++;
    		}
    }
    catch(IOException e){
    	System.out.println("ERROR");
    }
    		
    	}
    
    		
       public static String[][] getArrayofbooksandnumberofcopies(){
    	       return MemberandNumberofBorrowedBooks;
    	
    }
     
     
    // method when user want to return book
    	public static void ReturnBook( ) throws IOException{
    try{String Continue="";
    int vv=0;
    		while(true){
    		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    if(vv>0)
    {
    	System.out.println("if you want to make anothe return proces pres y or yes");
    	Continue=in.readLine();
    	if(!Continue.equalsIgnoreCase("y")||!Continue.equalsIgnoreCase("yes"))
       break;
    }
    		String Check="";
    System.out.println("Enter the ISBN");
    Check=in.readLine();
    if(Check.equals(""))
    	throw new IOException();
    if(!Check.toLowerCase().equals(Check.toUpperCase()))
    	throw new IOException();
    String ISBN=Check;
    
    System.out.println("Enter the ID");
    Check=in.readLine();
    if(Check.equals(""))
    	throw new IOException();
    if(!Check.toLowerCase().equals(Check.toUpperCase()))
    	throw new IOException();
    String ID=Check;
    		
    System.out.println("Enter the date Returned like this format dd/mm/yy ");
    Check=in.readLine();
    if(Check.equals(""))
    	throw new IOException();
    if(!Check.toLowerCase().equals(Check.toUpperCase()))
    	throw new IOException();
    String DateReturned=Check;
    
    	booksmanagement.Return(ISBN, 1)	;
    	if(booksmanagement.IS==-1)
    		throw new IOException();
    	else
    		for(int i=0; i<borrowedBooksInformationCounter;i++){
    		String [] a=borrowedBooksInformation[i].split(",");
    		if(ID.equals(a[1]))
    			borrowedBooksInformation[i]=(borrowedBooksInformation[i]+","+DateReturned);
    	
    		}	
    	vv++;}
    		}
    catch(IOException e){
    	System.out.println("Error \n wrong information");
    }
    		
    	}
      // method that use in removing member
    	public static void RemoveMember() throws IOException{
    try{
    		String Check="";
    		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
     System.out.println("Enter the ID");
     Check=in.readLine();
     if(Check.equals(""))
     	throw new IOException();
     if(!Check.toLowerCase().equals(Check.toUpperCase()))
     	throw new IOException();
     String ID=Check;
     boolean canRemove=false;
        for(int g=0;g<memberInformationCounter;g++)
    	{
    
    		          String [] just2=new String[7];
    		    for(int a=0;a<7;a++) 
    		    	just2[a]="";
    				  
    		    just2=MemberInformation[g].split(",");
    			
    		   
    	if(ID.equals(just2[0]) )
    			{
       
    	    for(int q=0; q<borrowedBooksInformationCounter;q++){
    			String [] just1=new String[5];
    			   for(int y=0;y<5;y++)
    				       just1[y]="";
    
    			just1=borrowedBooksInformation[q].split(",");
    	
      		
    	
      if(ID.equals(just1[1]))
    	  {canRemove=false;	
    		  if(!just1[4].equals(""))
    		  canRemove=true;
    			  
    		  
    	  }	
      }
    
    	    if(canRemove)
    		{
    			for(int v=g; v<memberInformationCounter ;v++){
    			   if(v+1!=memberInformationCounter)
    				MemberInformation[v]=MemberInformation[v+1];
    			}
    			MemberInformation[memberInformationCounter]=""; 
    			memberInformationCounter--;
    			 System.out.println("member Removed succesfully");
    			
    		}
    	    }	
    	}
        if(!canRemove)
        	System.out.println("cannot remove member");}
    catch(IOException e){
    	System.out.println("Error \n wrong ID");
    }
    	}
      //method to wright the array to the file again
    	public static void RewriteMemberinformation() throws IOException{
      
    		int ww=0;
    		BufferedWriter out= new BufferedWriter(new FileWriter("C:\\Users\\VooDoo\\Desktop\\LibrarySystem\\members.txt"));
    
    		while(ww<memberInformationCounter){
      	
    	
    	out.write(MemberInformation[ww]+"\n");
    	
    ww++;
    	}
    		out.close();
    
    }
    //method to give the administrator a list of books that it`s date returned expired
    public static String[] OverDueBooks()
     {
    	String  [] LatedBooks=new String[booksmanagement.getDataSize()];
    	
    	for(int e=0;e<booksmanagement.getDataSize();e++)
    		 LatedBooks[e]="";
    
    	 Date now=new Date();
    	 
    	 DateFormat now1 = DateFormat.getDateInstance(DateFormat.DATE_FIELD);
    	 
    	 String TodayDate=now1.format(now);
    	 String[] Just =new String[5];
    	   
      
    	 int i=0;
      
    	while( i<borrowedBooksInformationCounter )
      {
    		  for(int v = 0 ; v < 5; v++)
    		         Just[v]="";
    
    	
        String[] Just3=borrowedBooksInformation[i].split(",");
      for(int q=0;q<Just3.length;q++)
    	  Just[q]=Just3[q];
        
         if(Just[4].equals(""))
         {
        	 
    	  String[] Just1=new String[3];
        	
    	  String[] Just2=new String[3];
        	
    	  for(int u=0;u<3;u++)
        	 {
        		 Just1[u]="";
        		 Just2[u]="";
        		 
        	 }
        	 
    	  Just1=TodayDate.split("/");
        	
    	  Just2=Just[3].split("/");
        
    	  if((Integer.parseInt(Just1[2]))>(Integer.parseInt(Just2[2])))
        	 {
        		 LatedBooks[LatedBooksCounter]=booksmanagement.SearchWithISBN(Just[1]);		 
        	 LatedBooksCounter++;
         }
        	 else{
        		 if((Integer.parseInt(Just1[1]))>(Integer.parseInt(Just2[1])))
        		 {  LatedBooks[LatedBooksCounter]=booksmanagement.SearchWithISBN(Just[0]);		 
            	 LatedBooksCounter++;
             }
        		 else{
        			 if((Integer.parseInt(Just1[0]))>(Integer.parseInt(Just2[0])))
        			 {  LatedBooks[LatedBooksCounter]=booksmanagement.SearchWithISBN(Just[0]);		 
        	    	 LatedBooksCounter++;
        	     }
        	    
        		 }
        		 
        	 }
         }
      i++;
      }
      
    
    return LatedBooks;
    
    }
    
    //method to wright the array to the file again
    public static void RewriteBorrowedBooksinformation() throws IOException{
    
    	int ww=0;
    	BufferedWriter out= new BufferedWriter(new FileWriter("C:\\Users\\VooDoo\\Desktop\\LibrarySystem\\borrowedbooks.txt"));
    
    	while(ww<borrowedBooksInformationCounter){
    	
    
    out.write(borrowedBooksInformation[ww]+"\n");
    
    ww++;
    }
    	out.close();
    
    }
    
    public static int getOverDueBooksCounter(){
    	return LatedBooksCounter;
    }
    
    public static String[] getBorrowArray()
    {
    	return borrowedBooksInformation; 
    }
    }
    ..............
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    
    
    public class theMainClass  {
    
    	
    	public static void main(String[] args) throws Exception {
    try{	
    	new booksmanagement();
    	new Member();
    	booksmanagement.LoadBooksInFormation();
    	Member.LoadBorrowedBooksInFormation();
    	Member.LoadMemberInFormation();
    	int choose1=0;
    	int choose2=0;
    	int choose3=0;
    	BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    String[]Books=booksmanagement.getArrayOfBooks();
    String[] Members=Member.getMemberArray(); 
    String[] Borrow=Member.getBorrowArray();
    
    	if(Books[0]!=""){
    	System.out.println("the most popular books are:");
    System.out.println();
    	String[] MostPopularBooks =	booksmanagement.MostPopularBooks();
    for(int uu=0;uu<10;uu++)
    	System.out.println(MostPopularBooks[uu]);
    System.out.println();
    }
    if(Members[0]!="" || Books[0]!="" || Borrow[0]!=""){
    	System.out.println("the books which it`s returned date expired are:");
    System.out.println();
    
    String[] OverDueBooks=Member.OverDueBooks();
    for(int ff=0;ff<Member.getOverDueBooksCounter();ff++)
    	System.out.println(OverDueBooks[ff]);
       System.out.println();
    }
    
    while(true){
    	System.out.println("Welcome to the library please Enter ;\n 1 for Books process \n 2 for Member  and Borrowing process \n 0 for Exit");
    		choose1=Integer.parseInt(in.readLine());
    if(choose1 >2 || choose1<0)
    	throw new Exception();
    		switch (choose1){
    	case 1:{System.out.println("Welcome to the Books management please Enter ;\n 1 for insert new books \n 2 for Books search \n 3 for Add new copies \n 4 for Delete Book \n 0 for return to the main  ");
    		choose2=Integer.parseInt(in.readLine());
    		if(choose2 >4 || choose2<0)
    			throw new Exception();
    			
    		switch (choose2){
    			case 1:{
    				booksmanagement.TakeBooksInformationfromUser();
    				booksmanagement.RewriteBooksInformations();
    				break;
    			}
    			case 2:{System.out.println("Welcome to the  Books search  please Enter ;\n 1 for search with title \n 2 for search with ISBN \n 3 for search with author \n 4 for search with category \n 0 for return to the main  ");
    				choose3=Integer.parseInt(in.readLine());
    								switch(choose3){
    								case 1:{System.out.println("please Enter the title or part of it");
    								String title=in.readLine();
    									String[] Search=booksmanagement.SearchWithTitle(title);
    									for(int i=0;i<booksmanagement.getSearchTiltlarraySize();i++)
    										System.out.println(Search[i]);
    									break;
    								}
    								case 2:{System.out.println("please Enter the ISBN");
    								String ISBN=in.readLine();
    								if(!ISBN.toLowerCase().equals(ISBN.toUpperCase()))
    									throw new Exception();
    									
    								String Search=booksmanagement.SearchWithISBN(ISBN);
    									System.out.println(Search);
    									break;
    								}
    								case 3:{System.out.println("please Enter the author name");
    								String author=in.readLine();
    								if(author.toLowerCase().equals(author.toUpperCase()))
    									throw new Exception();
    									
    								String[] Search=booksmanagement.SearchWithAuthor(author);
    								for(int i=0;i<booksmanagement.getsearchResultCounterAuthorandCategory();i++)
    									System.out.println(Search[i]);
    								break;
    									
    								}
    								case 4:{System.out.println("please Enter the  category of the book");
    								String category=in.readLine();
    								if(category.toLowerCase().equals(category.toUpperCase()))
    									throw new Exception();
    									
    								String[] Search=booksmanagement.SearchWithCategory(category);
    								for(int i=0;i<booksmanagement.getsearchResultCounterAuthorandCategory();i++)
    									System.out.println(Search[i]);
    							
    								break;
    									
    								}
    								case 0:{
    									booksmanagement.RewriteBooksInformations();
    									Member.RewriteBorrowedBooksinformation();
    									Member.RewriteMemberinformation();
    									System.out.println("good bye");
    									break;
    								}
    								}
    			break;
    			}
    			case 3:{System.out.println("Enter the Book ISBN you want to ad copies for it");
    			String ISBN1=in.readLine();
    			if(!ISBN1.toLowerCase().equals(ISBN1.toUpperCase()))
    				throw new Exception();
    				
    			System.out.println("Enter the Number of Copies you want to add");
    			int NumberOfCopies=Integer.parseInt(in.readLine());
    				booksmanagement.AddNewCopies(ISBN1, NumberOfCopies);
    				break;
    				
    			}
    			
    			case 4:{System.out.println("Enter the Book ISBN you want to delete");
    			String ISBN=in.readLine();
    			if(!ISBN.toLowerCase().equals(ISBN.toUpperCase()))
    				throw new Exception();
    				
    			booksmanagement.DeleteBooks(ISBN);
    				booksmanagement.RewriteBooksInformations();
    				break;
    				
    			}
    			case 0:{
    				booksmanagement.RewriteBooksInformations();
    				Member.RewriteMemberinformation();
    				Member.RewriteBorrowedBooksinformation();
    				System.out.println("good bye");
    				break;
    			}
    			}
    			break;
    				}
    	
    	case 2:{System.out.println("Welcome to the Members management please Enter ;\n 1 for Register a new Member \n 2 for Borrowing  \n 3 for Returning Books \n 4 for Delete Member \n 0 fo return to the main ");
    		choose2=Integer.parseInt(in.readLine());
    		if(choose2 >4 || choose2<0)
    			throw new Exception();
    			
    		switch (choose2){
    		case 1:{
    			Member.TakeMemberInformationfromUser();
    			Member.RewriteMemberinformation();
    			break;
    			
    		}
    		
    		case 2:{
    			Member.CopyID();
    			Member.BorrowedBooks();
    			Member.RewriteBorrowedBooksinformation();
    			break;
    			
    		}
    		case 3:{
    			Member.ReturnBook();
    			Member.RewriteBorrowedBooksinformation();
    			booksmanagement.RewriteBooksInformations();
    			break;
    			
    		}
    		case 4:{
    			Member.RemoveMember();
    			Member.RewriteMemberinformation();
    			break;
    				
    		}
    		case 0:{
    			Member.RewriteMemberinformation();
    			Member.RewriteBorrowedBooksinformation();
    			booksmanagement.RewriteBooksInformations();
    			System.out.println("good bye");
    			break;
    		}
    		}
    		break;
    			}
    	case 0:{
    		booksmanagement.RewriteBooksInformations();
    		Member.RewriteMemberinformation();
    		Member.RewriteBorrowedBooksinformation();
    		System.out.println("good bye");
    		System.exit(0);
    	}
    	}
    	
    	
    	}
    }catch(Exception e){
    	System.out.println("ERROR please check your Entery");
    	
    }
    		
    		
    		
    		
    		
    	
    	}
    	
    	
    }
    Last edited by sheckoo; 12-06-2008 at 01:20 AM.

  2. #2
    sheckoo is offline Member
    Join Date
    Oct 2008
    Location
    Egypt
    Posts
    26
    Rep Power
    0

    Default

    Library System
    Project
    It is required to write a program that will maintain a library system. The system manages
    books information, library visitors, borrowing, ..... . The system stores for each book the title,
    author, publisher, ISBN, date of publication, number of copies, current available number of copies,
    and category. In a library, a member may borrow many books and at certain point of time there may
    be books which are not borrowed by any member. Your program should allow the user to execute
    the following commands:
    Books Management
    1- Insert new books: This command adds a new book to our library. The added data is stored
    in a file. The file is a text file that is comma delimited in which each entry (book) is found on a
    separate line. Each entry must contain the main book information mentioned before. An
    example of one line in the file is as follows:
    Core Java, Cay S. Horstmann, Prentice Hall PTR, 0-13-089468-0, December 01 2000, 5, 3, Programming
    2- Search for a book: The system should process a request by the user to look up information
    about a specific entry. The user can supply one or more of the following; book title (or part of
    it), author name, ISBN or category. The system should provide a list of books that matches the
    user request.
    3- Add new copy: The system should prompt the user to enter book ISBN and the number of
    its copies and update the Book entry in the file with the new number of copies.
    4- Delete book: The user should be prompted for the book ISBN and that entry should be
    deleted from the system (books file).
    Members Transactions
    1- Registration: Adding new user to our system which stores for each member his ID, name -
    the last and first, address, street, city, phone number, age, and email address. Data is stored in a
    separate file in the same format of books file (comma delimited, and each entry, user, is on a
    separate line).
    2- Borrowing: For each member who borrows a book, we store book ISBN, user ID, date
    issued, date due to return, date returned. Again, all borrowing data should be stored into a
    separate file. Also the number of available copies for that book should be decremented. A
    Member can not borrow more than 3 books at a time.
    3- Returning Book: When a user return a borrowed book back to the library, the entry for his
    borrowing action must be updated with the date returned. Also for book entry; the number of
    available copies of the book must be incremented.
    4- Remove Member: When a member wants to leave our system, the system must make sure
    that this user does not have any borrowed books (all entries in Borrowing file for this user must
    have its return date filled in)
    Administrative actions
    1- Over due books: A list of over-due books – books that were borrowed and their return date
    has been passed without returning it back – should be available for our system administrators.
    2- Most popular books: A list shows the most borrowed 10 books title should be printed at the
    beginning of our program.
    3- Quit: Exit the system, your program should terminate.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Are you willing to pay by the line or by the hour for this help?

    Just joking about the payment, but seriously, are you expect volunteers to read all of that?

  4. #4
    sheckoo is offline Member
    Join Date
    Oct 2008
    Location
    Egypt
    Posts
    26
    Rep Power
    0

    Default

    lol ,i dont know but can any body help me or tell me how to use oop
    in just the first class instead of the static methods and instances variables??

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. Another way is to place the tag &#91;code] at the top of your block of code and the tag &#91;/code] at the bottom, like so:

    Java Code:
    &#91;code]
      // your code block goes here.
      // note the differences between the tag at the top vs the bottom.
    &#91;/code]

Similar Threads

  1. Project Help
    By XxHEXSORxX in forum AWT / Swing
    Replies: 4
    Last Post: 01-28-2009, 10:01 AM
  2. Need Help With Project
    By maggie_2 in forum New To Java
    Replies: 1
    Last Post: 12-02-2008, 08:24 AM
  3. Could anyone help with project?
    By billdara in forum New To Java
    Replies: 1
    Last Post: 03-12-2008, 05:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •