متيكو المدير والمشرف
المدير العام الجنس : عدد المساهمات : 590 تاريخ الميلاد : 02/11/1989 تاريخ التسجيل : 28/08/2009 العمر : 35 الموقع : www.matti-king.blogspot.com العمل/الترفيه : يشرف عالمنتدى ويدرس المزاج : تعبان | موضوع: Java library code الجمعة مايو 27, 2011 2:17 pm | |
| [left] hiiiii every one this is a complete java library contain books ,magazine,stories ,movies and customer with a good idea and good options to choose ma design
the first one is the library application this is the code
package app;
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Date; import javax.swing.JOptionPane; import library.Book; import library.Magazine; import library.Movie; import library.Story; import library.customer; import app.Borrow; public class LibApp { public static void main(String[] a) throws NumberFormatException, IOException { JOptionPane.showMessageDialog(null,"Welcome to continue press OK", "The knowledge library",JOptionPane.INFORMATION_MESSAGE); System.out.println(" * "); System.out.println(" *** "); System.out.println(" ****** "); System.out.println(" ********** "); System.out.println("******Welcome The KNOWLEdge LIBRARY******"); System.out.println(" ********** "); System.out.println(" ****** "); System.out.println(" *** "); System.out.println(" * "); System.out.println("To Borrow and view the list press 6"); System.out.println("To Add New Item Press 9"); System.out.println("To Search press 10"); System.out.println("To Clear The Screen Press 0"); System.out.println("To Exit Press 8"); boolean exit = false; while(!exit) { customer[] mycustomer = LibApp.getcustomer(); Book[] myBooks = LibApp.getBook(); Magazine[] myMagazine = LibApp.getMagazine(); Story [] myStory=LibApp.getStory(); Movie [] myMovie=LibApp.getMovie(); BufferedReader userOption = new BufferedReader(new InputStreamReader(System.in)); float option = Float.parseFloat(userOption.readLine()); if (option == 1) { customer.displayAllMembersInfo(mycustomer); } else if (option == 2) { Book.displayAllBooksInfo(myBooks); } else if (option == 3) { Magazine.displayAllMagazineInfo(myMagazine); } else if (option ==4) { Story.displayAllStoryInfo(myStory); } else if(option==5) { Movie.displayAllMovieInfo(myMovie); } else if(option==6) { displayMenu(); } else if(option==7) { displayMainMenu(); } else if(option==0) { clearScreen(); } else if (option== { JOptionPane.showMessageDialog(null,"Your about to leave, press Ok to continue","The knowledge library",JOptionPane.WARNING_MESSAGE); System.exit(0); } else if (option==9) { WriteTextFile.addnewbook(); } else if(option ==10) { Search.search(); } else if(option ==11) { Borrow.BorrowItem(); } } }
public static void displayMainMenu() { System.out.println("To Borrow and view the list press 6"); System.out.println("To Add New Item Press 9"); System.out.println("To Search press 10"); System.out.println("To Clear The Screen Press 0"); System.out.println("To Exit Press 8"); }
public static void displayMenu() { System.out.println("What list would you like to view?"); System.out.println("For customers press 1"); System.out.println("For Books press 2"); System.out.println("For Magazine press 3"); System.out.println("For Stories press 4"); System.out.println("For Movies press 5"); System.out.println("To get back to the main minue press 7"); }
static Magazine[] getMagazine() throws IOException { Magazine[] magazine = new Magazine[2]; magazine[0] = new Magazine("abdf", "1254"); magazine[1] = new Magazine("dfref", "7886");
return magazine; }
@SuppressWarnings("deprecation") static customer[] getcustomer() throws IOException { int d = 25; int m = 2; int y = 1985; Date date = new Date(d, m, y); Date.parse("2/4/1987"); customer[] customers = new customer[3]; customers[0] = new customer("Matti", "Hatem", date, 15448); customers[1] = new customer("Sahand", "Khozavi", date, 48754); customers[2] = new customer("Sanarya", "Faraj", date, 8975); return customers; }
@SuppressWarnings("deprecation") static Book[] getBook() throws IOException { Book[] book = new Book[3]; int d = 25; int m = 2; int y = 1985; Date date = new Date(d, m, y); Date.parse("2/4/1987"); book[0] = new Book("dgg", "Harry Bote6", "Novel", "667", 005, date,date); book[1] = new Book("ABC", "Harry Boter", "Novel", "ddvd", 001, date,date); book[2] = new Book("def", "Harry Bote2", "Novel", "mmm", 002, date,date); return book; }
static Story[] getStory() throws IOException { Story[] story = new Story[3]; story[0] = new Story("King", "123"); story[1] = new Story("King2", "456"); story[2] = new Story("King3", "789"); return story; }
@SuppressWarnings("deprecation") static Movie[] getMovie() throws IOException { Movie[] movies = new Movie[3]; int d = 25; int m = 2; int y = 1985; Date date = new Date(d, m, y); Date.parse("2/4/1987"); movies[0] = new Movie("Avatar", "Adventure & fantasy", "James cameron","James cameron", "english", "USA", "James cameron", date); movies[1] = new Movie("The Godfather", "Drama,thriller","Francis ford coppola", "Mario puzo", "Albert S. rudy","english", "USA", date); movies[2] = new Movie("The Hangover", "Comedy ", "Todd phillips","John lucas", "Daniel goldberg", "english", "USA", date); return movies; }
public static void clearScreen() {
for (int i = 0; i < 500; i++) { System.out.println(); }
}
}[/left] | |
|