//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; contract LibrarySystem { struct Book { string author; string bookName; bool borrowed; } struct Borrower { string borrowerName; } struct Transaction{ uint bookId; uint borrowerId; address _; } mapping (uint => Book) private books; mapping (uint => Borrower) private borrowers; mapping (uint => Transaction) private transactions; uint private bookCounter; uint private borrowerCounter; uint private transactionCounter; address private creator; constructor() public { creator = msg.sender; bookCounter = 0; borrowerCounter = 0; transactionCounter = 0; } function addBook(string author, string bookName) public { bookCounter++; books[bookCounter] = Book(author, bookName, false); } function returnBook(uint id) public { require(books[id].borrowed == true); books[id].borrowed = false; } function borrowBook(uint _bookId, uint _borrowerId) public { require(books[_bookId].borrowed == true); transactionCounter++; transactions[transactionCounter] = Transaction(_bookId,_borrowerId,creator); } function addBorrower(string name) public { borrowerCounter++; borrowers[borrowerCounter] = Borrower(name); } function isBookBorrowed(uint id) public view returns(bool){ return books[id].borrowed; } // function viewTransactionById(uint id) public view returns(string, string){ // } }
0.4.25