Java Project
Java Project
The purpose of this project is to use various concepts of java and develop a program.
From this project we came to know about many different concepts in java.
Application of this project is that we can use this library management in an library.
A project report
Program code:
package com.company;
import java.util.Scanner;
import java.util.ArrayList;
abstract class Book{
int noOfBooks = 0;
ArrayList<String> array = new ArrayList<>();
Scanner sc = new Scanner(System.in);
void addBook(){
System.out.println("Enter the book name you want to add: ");
String temp = sc.nextLine();
array.add(temp); noOfBooks++;
System.out.println("Book has be successfully added");
this.displayBooks();
}
void displayBooks(){
System.out.println("The list of available books is: ");
for (String item: this.array) { if (item == null){
continue;
}
System.out.println(" * " +item);
}
}
}
class Library extends Book{
ArrayList<String> names = new ArrayList<>();
@Override
void register(){
System.out.println("Enter your name: ");
names.add(sc.nextLine());
//sc.nextLine();
System.out.println("** Registration successful **");
}
void displayUsers(){
System.out.println("Displaying all the registered people");
for (String name: names){
System.out.println(" * "+name);
}
}
void issueBook(){
System.out.println("Enter the name of book you want to issue: ");
String bookName = sc.nextLine(); //sc.nextLine();
System.out.println("Enter the name who wants to issue the book:
"); String name = sc.nextLine();
4. Abstract Class: Abstract class is a restricted class that cannot be used to create
objects (to access it, it must be inherited from another class).
5. Abstract Method: Abstract method can only be used in an abstract class, and
it does have any body. The body is provided by the subclass (inherited from).
7. Public static void main (string [] args): Public static void main (string [] args)
is java main method and is the entry point of any java program.
9. Method: A method is a block of code which only runs when it is called. You
can pass data, known as parameters, into a method. They are also known as
functions.
Working of program:
When the program starts to execute it first goes to main method called public
static void main (Strings [] args) and then it takes the input from user.
• Register
• Addbook
• Issuebook
• Returnbook
• Display All Available Books
• Display Registered people
After you have entered your choice then while loop gets started. It calls the
various method that we have used in our program.
Conclusion:
We developed a small software using java about library management system.
Reference:
www.google.com
www.javatpoint.com
www.wschoolsjava.com