//introducing state variable pragma solidity ^0.4.17; contract Car { string model; uint256 daily_rate; address creator; //store the address of the creator (BOB) address whoRentsCar; bool carIsRented; function Car(string argmodel,uint256 arg_daily_rate) payable public { model = argmodel; daily_rate = arg_daily_rate; creator =msg.sender; //assigning the value of owner in creator } modifier onlyAccessedBy(address _para) { require(msg.sender == _para); // If it is incorrect here, it reverts. _; // Otherwise, it continues. } function getCarModel() public view returns(string) { return model; } function setDailyRate(uint256 arg_dailyRate) onlyAccessedBy(creator) { require(carIsRented==false); daily_rate = arg_dailyRate; } function getDailyRate () public view returns (uint256) { return daily_rate; } function getBalance() public view returns(uint256) { return address(this).balance; } function rent() payable public { whoRentsCar = msg.sender; require(msg.value > 1 ether); carIsRented=true; } function return_car(uint256 noofdays) onlyAccessedBy(whoRentsCar) { require(carIsRented==true); carIsRented=false; msg.sender.transfer((address(this).balance) - (noofdays * daily_rate)); } function collect_fees() public onlyAccessedBy(creator) { require(carIsRented==false); msg.sender.transfer((address(this).balance)); } }