the 2nd line do?
contract HotelRoom {
enum Statuses { Vacant, Occupied };
Statuses currentStatus;
address payable public owner;
constructor() public {
owner = msg.sender;
currentStatus = Statuses.Vacant;
}
modifier onlyWhileVacant {
require(currentStatus == Statuses.Vacant, "Currently occupied."); //check room status
_;
}
modifier costs (uint _amount) {
require(msg.value >= _amount, "Not enough Ether proided."); //check payment amount
}
//updates currentStatus to Occupied. pays owner to book hotel room.
function book() payable onlyWhileVacant costs(2 ether) {
currentStatus = Statuses.Occupied;
owner.transfer(msg.value);
}
}
Hello! I have to correct you on this. The currentStatus should have its own constructor abidded to the format
Executes the code in the function
@zimmers25 why should currentStatus have its own constructor embedded? Where should its constructor be?
Ok
The value can fluctuate in the given parameters, having its own constructor will get things stable
Обсуждают сегодня