//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.25; contract LibraryContract { struct Book { string title; bool isBorrowed; address holder; } Book[] bookCollection; function addBook(string _title) public { bookCollection.push(Book(_title, false, address(0))); } function borrowBook(uint _index) public { require(!bookCollection[_index].isBorrowed); bookCollection[_index].isBorrowed = true; bookCollection[_index].holder = msg.sender; } function returnBook(uint _index) public { require(bookCollection[_index].isBorrowed); require(bookCollection[_index].holder == msg.sender); bookCollection[_index].isBorrowed = false; bookCollection[_index].holder = address(0); } function getBookHolder(uint _index) public view returns (address) { require(bookCollection[_index].isBorrowed); return bookCollection[_index].holder; } function isBookAvailable(uint _index) public view returns (bool) { return !bookCollection[_index].isBorrowed; } }
0.4.25