Question

In: Computer Science

Book SerialNum : String - Name: String – Author : String PublishYear: int - Edition:int Status...

Book

SerialNum : String -

Name: String –

  • Author : String

PublishYear: int -

  • Edition:int
  • Status : boolean

+ Book()

Book(String, String, String, int , int)+

+ setName(String) : void

+ setSerialNum(String) : void

+ setAuthor(String) : void

+ setEdition(int) : void

+ setYear(int) : void

+ getName():String

+ getAuthor():String

+ getYear(): int

+ getSerialNum(): String

+ getEdition():int

+ setAvailable() : void

+ setUnavailable(): void

checkAvailability(): boolean

-----------------------------------------------------------------------------------

Library

Name : String

Address: String

Static NUMBEROFBOOKS: int

BooksAtLibrray : ArrayList

LibraryIssues: TreeMap

Library()

Library(String, String)

addBook(Book): void

removeBook(Book) : Boolean

searchBookByName(Book) : Boolean

searchBookBySerialNumber(Book) : Boolean

checkBookAvailablity(Book): Boolean

createLibraryIssue(LibrrayIssue):Boolean

addLibraryIssue(LibraryIssue)

removeLibrrayIssue(LibrrayIssue):Boolean

searchLibrrayIssueByStuent(Student): List

searchLibraryIssuebyID(String IssueID):LibrrayIssue

searchLibraryIssueByBook(Book): LibraryIssue

--------------------------------------------------------------------------------------------------------------

Student

id : String

Name: String

Age : int

Student()

Student(String, String, int)

setName (String):void

SetAge(int):void

setId(String):void

getID():String

getName():String

getAge():int

---------------------------------------------------------------------------------------------------

LibraryIsuue

IssueID : String

borrower : Student

borrowedBook : Book

LibraryIssue()

LibraryIssue(String, Student , Book)

setIssueId(String):void

setBorrower(Student):void

setBorrowedBook(Book):void

getIssueID():String

getBorrowed():Student

getBorrowedBook():Book

----------------------------------------------------------------------------------------------------------

Librray

Main()

-----------------------------------------------------------------------------------------------------------------------------------------

Use the attached UML diagrams to build up your project classes

Make sure to put view for your project by Entering true data

You will need to add 5 books and 5 students and at least 3 LibraryIssues

LibraryIssues keeps track of the borrowed book

The librray uses all classes as mentioned in the UML diagram

You will need to check if book is available before borrowing it.

searchLibrrayIssueByStuent(Student): List

This method returns all book if borrowed by single student, as a student could borrow more than one book

Static NUMBEROFBOOKS: int

Each time you add a book the static variable is increased  and Each time a book is removed so the static variable is decreased.

createLibraryIssue(LibraryIssue) : boolean

changed the Boolean variable status in book element to false and return false if book is not available

removeLibrrayIssue(LibraryIssue):Boolean

changed the Boolean variable status in book element to true and return false if book is available

Note

LibrrayIssue and Book in the class Library should be List or map

Do not use array as the size is not fixed

Solutions

Expert Solution

import java.util.ArrayList;

import java.util.List;

import java.util.TreeMap;

public class LibraryManagementSystem {

    public static void main(String args[]){

    Book b1 = new Book("101", "Harry Potter and the Goblet of Fire", "JK Rolling", 1998, 5);

    Book b2 = new Book("102", "Harry Potter and the Soccer's  Stone", "JK Rolling", 1996, 4);

    Book b3 = new Book("103", " Autobiography of an Yogi", "James William", 2003, 7);

    Book b4 = new Book("104", "Think and become Rich","James Gosling", 1999, 8);

    Book b5 = new Book("105", "Julias Caesar", "William Shakespeare", 1887, 10);

    

    Student s1 = new Student("Chritian Bale", "134", 21);

    Student s2 = new Student("Julia Roberts", "135", 20);

    Student s3 = new Student("Robert Downey", "138", 19);

    Student s4 = new Student("Tom Hanks", "136", 22);

    Student s5 = new Student("Irrfan Khan", "137", 21);

    LibraryIssue l1= new LibraryIssue("Issue-101", s5, b1);

    LibraryIssue l2= new LibraryIssue("Issue-102", s2, b3);

    LibraryIssue l3= new LibraryIssue("Issue-103", s3, b4);

    LibraryIssue l4= new LibraryIssue("Issue-104", s4, b5);

    

    }

    

}

class Book{


private String SerialNum ;

private String Name;

private String Author;

private int PublishYear;

private int Edition;

private boolean Status;

Book(String SerialNum, String Name, String Author, int PublishYear,int Edition){

    this.SerialNum = SerialNum;

    this.Name =Name;

    this.Author= Author;

    this.PublishYear =PublishYear;

    this.Edition =Edition;

    }

public void setName(String Name){

    this.Name=Name;

}

public void setSerialNum(String SerialNum){

    this.SerialNum =SerialNum;

}

public void setAuthor(String Author){

    this.Author =Author;

}

public void setPublisherYear(String PublisherYear){

    this.PublisherYear =PublisherYear;

}

public void setEdition(String Edition){

    this.Edition= Edition;

}

public int getEdition(){

    return this.Edition;

}

public String getAuthor(){

    return this.Author;

}

public String getName(){

    return this.Name;

}

public String getSerialNum(){

    return this.SerialNum;

}

public int getPublisherYear(){

    return this.PublisherYear;

}

public void setAvailable(){

    this.Status =true;

}

public void setUnAvailable(){

    this.Status =false;

}

public boolean checkAvailability(){

    return this.Status;

}

}


class Library{

    private String Name;

private String Address;

private static int NUMBEROFBOOKS;

private ArrayList<Book> BooksAtLibrray  = new ArrayList<>();

private ArrayList<LibraryIssue> LibraryIssues = new ArrayList<>();

Library(String Name, String Address){

    this.Name =Name;

    this.Address =Address;

}

public void addBook(Book book){

    this.BooksAtLibrray.add(book);

    NUMBEROFBOOKS++;

}

public boolean removeBook(Book book){

if(this.BooksAtLibrray.contains(book))

{   

     NUMBEROFBOOKS--;

     return this.BooksAtLibrray.remove(book);

     

}

else{

     return false;

}

}

public boolean searchBookByName(Book book){

    if(!this.BooksAtLibrray.isEmpty())

{

     for(Book myBook: this.BooksAtLibrray){

        if(myBook.getName() == book.getName()){

            return true;

        }

     }

     return false;

}

else{

     return false;

}

}

public boolean searchBookBySerialNumber(Book book) {

    if(!this.BooksAtLibrray.isEmpty())

    {

        for(Book myBook: this.BooksAtLibrray){

           if(myBook.getSerialNum() == book.getSerialNum()){

               return true;

           }

        }

        return false;

    }

    else{

        return false;

    }

}

public boolean checkBookAvailablity(Book book){

    if(!this.BooksAtLibrray.isEmpty())

    {   

        return book.checkAvailability();

    }

    else{

        return false;

    }

}

public boolean createLibraryIssue(LibrrayIssue libraryIssue){

           if(libraryIssue.getBorrowedBook().checkAvailability()){

               libraryIssue.getBorrowedBook.setUnAvailable();

               return true;

           }

           else{

               return false;

           }

}

public void addLibraryIssue(LibraryIssue libraryIssue){

    this.LibraryIssues.add(libraryIssue);

}

public boolean removeLibrrayIssue(LibrrayIssue libraryIssue){

if(libraryIssue.getBorrowedBook().checkAvailability()){

    return false;

}

else{

    libraryIssue.getBorrowedBook().setAvailable();

    return true;

}

}

public List<Book> searchLibrrayIssueByStudent(Student student){

List<Book> mylist = new ArrayList<>();

for(LibraryIssue ls : this.LibraryIssues){

    if(ls.getBorrowed().equals(student)){

        mylist.add(ls.getBorrowedBook());

    }

}

return mylist;

}

public LibraryIssue searchLibraryIssuebyID(String IssueID){

    for(LibraryIssue ls : this.LibraryIssues){

        if(ls.getIssueID() ==IssueID)

            return ls;

    }

    return null;

}

public LibrrayIssue searchLibraryIssueByBook(Book book){

    for(LibraryIssue ls : this.LibraryIssues){

        if(ls.getBorrowedBook().equals(book))

            return ls;

    }

    return null;

}

}



class Student{

private String id ;

private String Name;

private int Age ;

Student(String Name,String id, int Age){

    this.Age =Age;

    this.Name =Name;

    this.id =id;

}


public void setName(String Name){

    this.Name= Name;

}

public void setId(String id){

    this.id = id;

}

public void setAge(String Age){

    this.Age= Age;

}

public String getName(){

    return this.Name;

}

public String getId(){

    return this.id;

}

public int getAge(){

    return this.Age;

}

}

class LibraryIssue{

private String IssueID ;

private Student borrower;

private Book borrowedBook;


LibraryIssue(String IssueID, Student student  , Book book){

    this.IssueID =IssueID;

    this.borrower = student;

    this.borrowedBook =book;

}

public void setIssueId(String issueID){

    this.IssueID =issueID;

}

public void setBorrower(Student student){

    this.borrower = student;

}

public void setBorrowedBook(Book book){

    this.borrowedBook =book;

}

public String getIssueID(){

    return this.IssueID;

}

public Student getBorrowed(){

    return this.borrower;

}

public Book getBorrowedBook(){

    return this.borrowedBook;

}

}


Related Solutions

int main() {    footBallPlayerType bigGiants[MAX];    int numberOfPlayers;    int choice;    string name;   ...
int main() {    footBallPlayerType bigGiants[MAX];    int numberOfPlayers;    int choice;    string name;    int playerNum;    int numOfTouchDowns;    int numOfcatches;    int numOfPassingYards;    int numOfReceivingYards;    int numOfRushingYards;    int ret;    int num = 0;    ifstream inFile;    ofstream outFile;    ret = openFile(inFile);    if (ret)        getData(inFile, bigGiants, numberOfPlayers);    else        return 1;    /// replace with the proper call to getData    do    {       ...
Consider the following class: class Person {         String name;         int age;        ...
Consider the following class: class Person {         String name;         int age;         Person(String name, int age){                this.name = name;                this.age = age;         } } Write a java program with two classes “Teacher” and “Student” that inherit the above class “Person”. Each class has three components: extra variable, constructor, and a method to print the student or the teacher info. The output may look like the following (Hint: you may need to use “super”...
int bintodec(string); // converts a binary number (represented as a STRING) to decimal int hextodec(string); //...
int bintodec(string); // converts a binary number (represented as a STRING) to decimal int hextodec(string); // converts a hexadecimal number (represented as a STRING) to decimal string dectobin(int); // converts a decimal number to binary (represted as a STRING) string dectohex(int); // converts a decimal number to hexadecimal (represted as a STRING) //the addbin and addhex functions work on UNsigned numbers string addbin(string, string); // adds two binary numbers together (represented as STRINGS) string addhex(string, string); // adds two hexadecimal...
Given: class Monster {     private:     string name;     int dangerLevel;     public:     Monster(sting, int);     virtual void hunt()
Given: class Monster {     private:     string name;     int dangerLevel;     public:     Monster(sting, int);     virtual void hunt() = 0;     virtual void fight(Monster&);     string getName() const; }; class GiantMonster : public Monster {     protected:         int height;          public:         GiantMonster(string, int, int);         virtual void trample(); }; class Dinosaur : public GiantMonster {     public:     Dinosaur(string, int, int);     void hunt();     void roar(); }; class Kraken : protected GiantMonster {     public:     Kraken(string, int, int);     virtual void hunt();     void sinkShip(); }; Indicate if the code snippets below are...
string getStyle() ; int getNumOfBedRooms() ; int getNumOfBathRooms(); int getNumOfCarsGarage(); int getYearBuilt(); int getFinishedSquareFootage() ; double...
string getStyle() ; int getNumOfBedRooms() ; int getNumOfBathRooms(); int getNumOfCarsGarage(); int getYearBuilt(); int getFinishedSquareFootage() ; double getPrice(double p) ; double getTax(double t) ; void print() ; houseType(); houseType(string s, int numOfBeds, int numOfBaths, int numOfCars, int yBuilt, int squareFootage, double p, double t); private: string style; int numOfBedrooms; int numOfBathrooms; int numOfCarsGarage; int yearBuilt; int finishedSquareFootage; double price; double tax; }; Questions a.Write the definition of the member function set so that private members are set accordingy to the parameters....
binarySearchLengths(String[] inArray, String search, int start, int end) This method will take in a array of...
binarySearchLengths(String[] inArray, String search, int start, int end) This method will take in a array of strings that have been sorted in order of increasing length, for ties in the string lengths they will be in alphabetical order. The method also takes in a search string and range of indexes (start, end). The method will return a String formatted with the path of search ranges followed by a decision (true or false), see the examples below. Example 1: binarySearchLengths({"a","aaa","aaaaa"},"bb",0,2) would...
The name of the experiment is Preparation of Synthetic Banana oil. The name of the author...
The name of the experiment is Preparation of Synthetic Banana oil. The name of the author of the book is John Lehma. chapter 5. (incase needed, we used 20.o mmol of isopentyl and 40 mmol of glacial acetic acid) In the ''understanding experiment'' section, it was stated that the reaction of an equimolar mixture of isopentyl alcohol and acetic acid will produce, at most, 67% of the theoretical amount of isopentyl acetate. verify this with an equilibrium constant calculation, using...
class ArrayStringStack { String stack[]; int top; public arrayStringStack(int size) { stack = new String[size]; top...
class ArrayStringStack { String stack[]; int top; public arrayStringStack(int size) { stack = new String[size]; top = -1; } //Assume that your answers to 3.1-3.3 will be inserted here, ex: // full() would be here //empty() would be here... //push() //pop() //displayStack() } 1. Write two boolean methods, full( ) and empty( ). 2. Write two methods, push( ) and pop( ). Note: parameters may be expected for push and/or pop. 3. Write the method displayStack( ) that prints the...
protected String name;                                      &nbsp
protected String name;                                                                                                           protected ArrayList<Stock> stocks;     protected double balance;                                                                              + Account ( String name, double balance) //stocks = new ArrayList<Stock>() ; + get and set property for name; get method for balance + void buyStock(String symbol, int shares, double unitPrice ) //update corresponding balance and stocks ( stocks.add(new Stock(…..)); ) + deposit(double amount) : double //returns new balance                                                                 + withdraw(double amount) : double //returns new balance + toString() : String                                                                  @Override     public String toString(){         StringBuffer str =...
Given a string and a non-negative int n, we'll say that the front of the string...
Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front; frontTimes("Chocolate", 2) → "ChoCho" frontTimes("Chocolate", 3) → "ChoChoCho" frontTimes("Abc", 3) → "AbcAbcAbc" Must work the following problem using a while loop or do while.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT