0

a beginner contract developer here

    pragma solidity ^0.5.0;
contract waterBill{
    address admin;
    uint public rateperliter;
    struct Individual{
        string name;
        string addr;
        uint water;
        uint BillAmount;
    }
    mapping (address=>Individual) individual;
    address[] Useraccts;
    constructor() public{
        admin=msg.sender;
    }
    modifier onlyAdmin(){
        require(msg.sender==admin,"Only Admin has access to this function");_;
    }
     event NewUser(
         string _name,
         address _address,
         uint _waterconsumed
         );
     event BillGenerated(
         address _address,
      uint billamount
         );
    function setUser(string memory _name,address _address,uint _waterconsumed,string memory _Physicaladdress) public onlyAdmin()
    {
        Individual memory User=individual[_address];
        User.name=_name;
        User.water=_waterconsumed;
        User.addr=_Physicaladdress;
        Useraccts.push(_address) -1;
    emit NewUser(_name,_address,_waterconsumed);
     }
     function setBill(address _address) public onlyAdmin() returns(uint){
         individual[_address].BillAmount=individual[_address].water*rateperliter;

    emit BillGenerated(_address,individual[_address].BillAmount);
       return individual[_address].BillAmount;
   }
    function getBill(address _address) view public returns(uint){
        return individual[_address].BillAmount;
    }
    function setRate(uint _rate) public onlyAdmin(){
        rateperliter=_rate;
    }
}

while running this contract in remix IDE, im able to set a new user(setUser), im able to set the rate, but yet when i call setBill, the result is not updated when i call from get Bill

can anyone help me out?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.