-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary solidity.sol
76 lines (65 loc) · 2.02 KB
/
library solidity.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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);
}
}