-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRenting.sol
More file actions
34 lines (27 loc) · 735 Bytes
/
Copy pathRenting.sol
File metadata and controls
34 lines (27 loc) · 735 Bytes
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
pragma solidity ^0.4.18;
contract Renting {
mapping (bytes32 => bool) public roomBooked;
bytes32[] public roomNumber;
function Renting(bytes32[] rooms) public {
roomNumber = rooms;
}
function bookRoom(bytes32 room) public {
require(isvalidRoom(room));
roomBooked[room] = true;
}
function unbookRoom(bytes32 room) public {
require(isvalidRoom(room));
roomBooked[room] = false;
}
function isRoomEmpty(bytes32 room) view public returns (bool) {
return roomBooked[room];
}
function isvalidRoom(bytes32 room) view public returns (bool) {
for(uint i = 0; i < roomNumber.length; i++) {
if (roomNumber[i] == room){
return true;
}
}
return false;
}
}