Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Library Management System

  Asked By: Elena    Date: Nov 30    Category: Java    Views: 2612
  

I have made 3 different classes for the library management system
I need help to make the 4th class called IOLibraryManagmentSystem that consists at using java.io package for writing and reading from the file library.txt that contains all the new added books to library


public class Book {
private String title;
private String author;
private int publicationYear;
private double price;
public Book(){
this.title= " ";
this.author=" ";
this.publicationYear=0;
this.price=0;
}
public String getAuthor(){
return author;
}
public void setAuthor(String author){
this.author=author; }
public int getPublicationYear(){
return publicationYear;}
public void setPublicationYear(int publicationYear){
this.publicationYear=publicationYear;}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public Double getPrice() {
return price;
}

public void setPrice(Double price) {
this.price = price;
}


public String toString(){
return (title+author+publicationYear+price);

}
}
---------------------------------------
public abstract class Library {
public static Book book;
public Library(Book b){
book=b;
}

public abstract void addBook(Book book);

public abstract void showAllBooks();

}
----------------------------------------

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class LibraryManagementSystem {
static List<Book> books = new ArrayList<Book>();

public String tab [];
String n;
static Book b;
public LibraryManagementSystem(Book b){

tab=new String[10];
for (int i = 0; i < 10; i++)
tab[i]=" ";
}


public static void showAllBooks() {
System.out.append((CharSequence) b);
}
public static void main (String [] args){
System.out.println("Library Management System");
System.out.println("Press 1 to add Book");
System.out.println("Press 2 to show all books");
System.out.println("Press 3 to exit");
Scanner c = new Scanner(System.in);
int choice = c.nextInt();
do {
switch (choice) {
case 1:
addBook(b);
break;
case 2:
showAllBooks();
break;

default:
System.out.println("Invalid input");
break;
}
c = new Scanner(System.in);
choice = c.nextInt();
} while (choice > 0 && choice < 2);
}

private static void addBook(Book b) {
System.out.println("Enter Book name, The author, Publication year and the price");
Scanner c = new Scanner(System.in);
String title = c.nextLine();
String author = c.nextLine();
int publicationYear = c.nextInt();
Double price = c.nextDouble();

Book book = new Book();
books.add(book);

}
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Library Management System Or get search suggestion and latest updates.




Tagged: