Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 47 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. pragma solidity ^0.4.16;
  2.  
  3. contract BikeContract {
  4.     address bikeOwner;
  5.     Condition bikeCondition;
  6.     address[] riders;
  7.     Battery bikeBattery;
  8.    
  9.     struct Battery{
  10.         uint capacity;
  11.         uint chargeLevel;
  12.     }
  13.    
  14.     enum Condition{
  15.         in_use,
  16.         broken,
  17.         repaired,
  18.         available
  19.     }
  20.    
  21.     function changeStatus(Condition s) public returns (string) {
  22.         if (bikeCondition == Condition.broken && (s == Condition.in_use || s == Condition.available)) {
  23.             bikeBattery.chargeLevel -= 20;
  24.             return "bike must be repaired first";
  25.         } else {
  26.             bikeCondition = s;
  27.             bikeBattery.chargeLevel -= 20;
  28.             return "color changed";
  29.         }
  30.     }
  31.    
  32.     constructor() public {
  33.         bikeCondition = Condition.available;
  34.         bikeBattery.chargeLevel = 100;
  35.         riders.push(msg.sender);
  36.         bikeOwner = msg.sender;
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top