0% found this document useful (0 votes)
2 views10 pages

Library Managment System

The document contains a Java implementation of a library management system with classes for Book, LibraryMember, Library, Publisher, Transaction, and Payment. Each class includes constructors, getters, setters, and methods for displaying details and managing data. The main class demonstrates the creation and manipulation of these objects, showcasing their functionalities.

Uploaded by

theshahzaib27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

Library Managment System

The document contains a Java implementation of a library management system with classes for Book, LibraryMember, Library, Publisher, Transaction, and Payment. Each class includes constructors, getters, setters, and methods for displaying details and managing data. The main class demonstrates the creation and manipulation of these objects, showcasing their functionalities.

Uploaded by

theshahzaib27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

/*

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this
template
*/
package com.mycompany.library_management_system;

/**
*
* @author Aslam Computer
*/
public class Book {
private String title;
private String author;
private String ISBN;
private double price;
private static int totalCopies = 0;

// Parameterized Constructor
public Book(String title, String author, String ISBN, double price) {
this.title = title;
this.author = author;
this.ISBN = ISBN;
this.price = price;
totalCopies++;
}

// Copy Constructor

public Book(Book book)


{
this.title = book.title;
this.author=book.author;
this.ISBN = book.ISBN;
this.price =book.price;
totalCopies++;
}

// Getter and Setters


public String getTitle()
{
return title;
}
public void setTitle()
{
this.title = title;
}
public String getAuthor()
{
return author;
}
public void setAuthor()
{
this.author = author;
}
public String getISBN()
{
return ISBN;
}
public void setISBN()
{
this.ISBN = ISBN;
}
public double getPrice()
{
return price;
}
public void setPrice()
{
this.price = price;
}

// Display Book Details

public void displayBookDetails()


{
System.out.println("Title: "+title+", Author: "+author+", ISBN: "+ISBN+",
Price: "+price);
}

// Static Method

public static void showTotalCopies()


{
System.out.println("Total Copies: "+totalCopies);
}

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this
template
*/
package com.mycompany.library_management_system;

/**
*
* @author Aslam Computer
*/
public class LibraryMember {
private int memberId;
private String name;
private String email;

// Default Constructor
public LibraryMember()
{

// Parameterized Constructor

public LibraryMember(int memberId,String name,String email)


{
this.memberId = memberId;
this.name = name;
this.email = email;
}

// Shallow Copy Constructor

public LibraryMember (LibraryMember member)


{
this.memberId = member.memberId;
this.name = member.name;
this.email = member.email;
}

// Deep Copy Constructor

public LibraryMember deepCopy(LibraryMember member)


{
return new LibraryMember(member.memberId,member.name,member.email);
}

// Getter & Settter

public int getMemberId()


{
return memberId;
}
public void setMemberId()
{
this.memberId = memberId;
}
public String getName()
{
return name;
}
public void setName()
{
this.name = name;
}
public String getEmail()
{
return email;
}
public void setEmail()
{
this.email = email;
}

// Display Member Details


public void displayMemberDetails(){
System.out.println("ID: "+memberId+", Name: "+name+", Email: "+email);
}

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this
template
*/
package com.mycompany.library_management_system;

/**
*
* @author Aslam Computer
*/
public class Library {
private String libraryName;
private String location;

// Parameterized Constructor
public Library(String libraryName,String location)
{
this.libraryName = libraryName;
this.location = location;
}

// Copy Constructor

/* public Library(Library library)


{
this.libraryName = library.libraryName;
this.location = library.location;

}*/

// Display Library Details

public void displayLibraryInformation(){


System.out.println("Library: "+libraryName+", Locaton: "+location);
}
}

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this
template
*/
package com.mycompany.library_management_system;

/**
*
* @author Aslam Computer
*/
public class Publisher {
private String publisherName;
private String publisherAddress;
private int publisherClass;

// Parameterized Constructor

public Publisher(String publisherName,String publisherAddress,int


publisherClass)
{
this.publisherName = publisherName;
this.publisherAddress = publisherAddress;
this.publisherClass = publisherClass;
}

// Getter and Setter

public String getPublisherName()


{
return publisherName;
}
public void setPublisherName()
{
this.publisherName = publisherName;
}
public String getPublisherAddress()
{
return publisherAddress;
}
public void setPublisherAddress()
{
this.publisherAddress = publisherAddress;
}
public int getPublisherClass()
{
return publisherClass;
}
public void setPublisherClass()
{
this.publisherClass = publisherClass;
}

// Inout and Display Publisher Details

public void inputPublisherDetails(String pubName,String pubAddress,int


pubClass)
{
this.publisherName = pubName;
this.publisherAddress = pubAddress;
this.publisherClass = pubClass;
}

public void displayPublisherDetails()


{
System.out.println("Publisher Name: "+publisherName+", Publisher Address:
"+publisherClass+", Publisher Class: "+publisherClass);
}
}

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this
template
*/
package com.mycompany.library_management_system;

/**
*
* @author Aslam Computer
*/
public class Transaction {
private int transactionalId;
private int memberId;
private String bookISBN;
private String transactionDate;

// Parameterized Constructor

public Transaction(int transactionId,int memberId,String bookISBN,String


transactonDate)
{
this.transactionalId = transactionId;
this.memberId = memberId;
this.bookISBN = bookISBN;
this.transactionDate = transactionDate;
}

// Getter and Setter Methods

public int getTransactionalId()


{
return transactionalId;
}
public void setTransactionId()
{
this.transactionalId = transactionalId;
}
public int getMemberId()
{
return memberId;
}
public void setMemberId()
{
this.memberId = memberId;
}
public String getBookISBN()
{
return bookISBN;
}
public void setBookISBN()
{
this.bookISBN = bookISBN;
}
public String getTransactionDate()
{
return transactionDate;
}
public void setTransactionDate()
{
this.transactionDate = transactionDate;
}

// Input and Display Tranaction Details

public void inputTransactionDetails(int TransId,int memId,String isbn,String


transDate)
{
this.transactionalId = TransId;
this.memberId = memId;
this.bookISBN = isbn;
this.transactionDate = transDate;
}

public void displayTransactionDetails()


{
System.out.println("Transactional ID:"+transactionalId+", Member ID:
"+memberId+", Book ISBN"+bookISBN+", Transaction Date: "+transactionDate);
}
}

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this
template
*/
package com.mycompany.library_management_system;

/**
*
* @author Aslam Computer
*/
public class Payment {
private int paymentId;
private double amount;
private String paymentDate;
private int fine;

// Parameterized Constructor

public Payment(int paymentId,double amount,String paymentDate,int fine)


{
this.paymentId = paymentId;
this.amount = amount;
this.paymentDate = paymentDate;
this.fine = fine;
}

// Getter and Setter Methods

public int getPaymentId()


{
return paymentId;
}
public void setPaymentId()
{
this.paymentId = paymentId;
}
public double getAmount()
{
return amount;
}
public void setAmount()
{
this.amount = amount;
}
public String getPaymentDate()
{
return paymentDate;
}
public void setPaymentDate()
{
this.paymentDate = paymentDate;
}
public int getFine()
{
return fine;
}
public void setFine()
{
this.fine = fine;
}

// Culate fine and display Payment Details

public void culculateFine(int totalDays,int finePerDay)


{
this.fine = totalDays * finePerDay;
}

public void displayPaymentDetails()


{
System.out.println("Payment ID: "+paymentId+", Amount: "+amount+", Payment
Date: "+paymentDate+", Fine: "+fine);
}

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
*/

package com.mycompany.library_management_system;

/**
*
* @author Aslam Computer
*/
public class Library_Management_System {

public static void main(String[] args) {


Book book1 = new Book("The Great Gatsby", "F. Scott Fitzgerald", "123-
456789", 150.50);
Book book2 = new Book("1984", "George Orwell", "789-456123", 200.75);
Book book3 = new Book(book1);

book1.displayBookDetails();
book2.displayBookDetails();
book3.displayBookDetails();
Book.showTotalCopies();

// Creating LibraryMember Instances

LibraryMember member1 = new LibraryMember(1, "Alice", "[email protected]");


LibraryMember member2 = new LibraryMember(2, "Bob", "[email protected]");
LibraryMember member3 = new LibraryMember(member1);

member1.displayMemberDetails();
member2.displayMemberDetails();
member3.displayMemberDetails();

Library library1 = new Library("Central Library", "Downtown");


Library library2 = new Library("Main Library","CentralTown");
// Library library3 = new Library(library1);

library1.displayLibraryInformation();;
library2.displayLibraryInformation();
// library3.displayLibraryInformation();;

// Creating publisher instances

Publisher publisher1 = new Publisher("Penguin Random House", "New York,


USA", 1);
Publisher publisher2 = new Publisher("Sparrow Random House", "Sydney,
Austrailia", 2);
Publisher publisher3 = new Publisher ("Random House", "London, England", 3);

publisher1.displayPublisherDetails();
publisher2.displayPublisherDetails();
publisher3.displayPublisherDetails();

// Creating Transaction Instances

Transaction transaction1 = new Transaction(1001, 1, "123-456789", "2025-03-


01");
Transaction transaction2 = new Transaction(1002, 2, "123-456789", "2025-04-
04");
transaction1.displayTransactionDetails();
transaction2.displayTransactionDetails();

// Creating Payment Instances

Payment payment1 = new Payment(5001, 300.00, "2025-03-03", 0);


Payment payment2 = new Payment(5002, 400.00, "2025-03-04", 0);
Payment payment3 = new Payment(5003, 500.00, "2025-04-04", 1);
payment1.culculateFine(5, 10);
payment2.culculateFine(10, 10);
payment3.culculateFine(15, 10);

payment1.displayPaymentDetails();
payment2.displayPaymentDetails();
payment3.displayPaymentDetails();
}
}

You might also like