-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontract.sol
More file actions
98 lines (85 loc) · 2.68 KB
/
contract.sol
File metadata and controls
98 lines (85 loc) · 2.68 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
pragma solidity ^0.4.17;
contract rent{
struct FlatInfo {
string landlordName;
string email;
int phoneno;
string Houseaddress;
string city;
int rentAmount;
int BHK;
int securityFee;
bool negotiable;
bool booked;
address landlordAddress;
}
struct Tenant {
string name;
string email;
int phoneno;
string city;
int startRentRange;
int endRentRange;
int BHK;
int durationStay;
address tenantAddress;
}
FlatInfo[] public flats;
FlatInfo[] public searchedFlats;
Tenant[] public tenant;
FlatInfo public tempFlat;
Tenant public tempTenant;
mapping(string => uint) mp;
function setFlatInfo(string landlordName, string email, int phoneno, string Houseaddress, string city, int rentAmount,int BHK ,int securityFee,bool negotiable) public
{
tempFlat.landlordAddress = msg.sender;
tempFlat.landlordName = landlordName;
tempFlat.phoneno = phoneno;
tempFlat.email = email;
tempFlat.Houseaddress = Houseaddress;
tempFlat.city = city;
tempFlat.rentAmount = rentAmount;
tempFlat.BHK = BHK;
tempFlat.securityFee = securityFee;
tempFlat.negotiable = negotiable;
tempFlat.landlordName = landlordName;
if(mp[city]>5)
{
tempFlat.rentAmount = tempFlat.rentAmount + 500;
}
flats.push(tempFlat);
}
function setTenant(string name,string email, int phoneno, string city, int startRentRange, int endRentRange, int BHK, int durationStay) public
{
mp[city] = mp[city] + 1;
for(uint k=0; k< flats.length; k++)
{
if(flats[k].booked == false && keccak256(bytes(city)) == keccak256(bytes(flats[k].city))
&& startRentRange <= flats[k].rentAmount && tempTenant.endRentRange >= flats[k].rentAmount)
{
searchedFlats.push(flats[k]);
}
}
tempTenant.tenantAddress = msg.sender;
tempTenant.name=name;
tempTenant.email=email;
tempTenant.phoneno=phoneno;
tempTenant.city=city;
tempTenant.startRentRange=startRentRange;
tempTenant.endRentRange=endRentRange;
tempTenant.BHK=BHK;
tempTenant.durationStay=durationStay;
tenant.push(tempTenant);
}
function bookFlat(address fd) public payable {
fd.transfer(msg.value);
for(uint i=0;i<flats.length;i++)
{
if(flats[i].landlordAddress == fd)
{
flats[i].booked = true;
break;
}
}
}
}