-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37e995e
commit 7da62f8
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
pragma solidity ^0.4.0; | ||
|
||
contract Library | ||
{ | ||
uint time; | ||
uint validity; | ||
uint fine; | ||
uint f; | ||
uint blc; | ||
|
||
struct books{ | ||
string bookname; | ||
string authorname; | ||
uint available; | ||
uint ISBN; | ||
} | ||
mapping(address=>books)book; | ||
struct users{ | ||
string username; | ||
uint id; | ||
} | ||
mapping(address=>users)people; | ||
|
||
function addbook(address _ass,string bookname,string authorname)public | ||
{ | ||
book[_ass].bookname=bookname; | ||
book[_ass].authorname=authorname; | ||
} | ||
|
||
|
||
function susers(address _abb,string username,uint id)public | ||
{ | ||
people[_abb].username=username; | ||
people[_abb].id=id; | ||
} | ||
|
||
function getbook(address _add,string bookname,string authorname)public view returns(string) | ||
{ | ||
book[_add].bookname=bookname; | ||
book[_add].authorname=authorname; | ||
|
||
} | ||
|
||
function Booksearch(address ISBN)public returns(string) | ||
{ | ||
if(book[ISBN].available>0) | ||
{ | ||
return("book is available"); | ||
} | ||
else | ||
{ | ||
return("book is not available"); | ||
} | ||
} | ||
function bookreturn(address ISBN)public{ | ||
book[ISBN].available++; | ||
uint fine=1; | ||
uint returntime=now; | ||
|
||
if(returntime > validity) { | ||
uint blc = returntime - validity; | ||
blc=blc/60; | ||
fine= blc * fine; | ||
f =fine; | ||
} | ||
} | ||
function penalty() public { | ||
time=now; | ||
validity = time + 2 * 1 minutes; | ||
} | ||
|
||
function getfine() public view returns(uint) { | ||
return(f); | ||
} | ||
} | ||
|