Instructions:- PLEASE USE JAVA TO DO THIS QUESTION Should write your approach wh
ID: 3820722 • Letter: I
Question
Instructions:- PLEASE USE JAVA TO DO THIS QUESTION
Should write your approach which carries 50% marks.
Should submit only the pdf and no word document.
Should paste the screen shot of your input and output.
This question is based on Inheritance: -
Create a class Book with the following members:Accession number, Name of the author, Title of the book, Year of Publication,Publisher’s Name, Cost of the book and Availability Create a class Membership with the following members:Member id, Name, Maxbooks Derive a class Library information_system from Book and Member. Include the following member functions:
1. Issue a book after checking member id, book id, Availability of the book and Maxbooks available for the member.
2. Update availability of book and Maxbooks after each transaction. (Contd..)
3. Display a member’s information given member id
Explanation / Answer
In Java you cannot extend two classes as Java does not support Multiple Inheritance.
For the above question you may have following code:
class Book
{
int Accession_number;
String Name_of_the_author;
String Title_of_the_book;
String Year_of_Publication;
String Publisher’s_Name;
int Cost_of_the_book;
int Availability;
}
class Membership
{
int Member_id;
String Name;
String Maxbooks;
}
class Library_information_system extends Membership
{
void issueBook()
{
if(this.Availability!=0 && this.Maxbooks !=0)
{
system.out.println("Book Allocated");
}
}
void update()
{
Availability=Availability-1;
Maxbooks=Maxbooks-1;
}
void diaply(int Member_id)
{
System.out.println("Member Name:"+Name);
System.out.println("Maxbooks:"+Maxbooks);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.