Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.16;
- contract BikeContract {
- address bikeOwner;
- Condition bikeCondition;
- address[] riders;
- Battery bikeBattery;
- struct Battery{
- uint capacity;
- uint chargeLevel;
- }
- enum Condition{
- in_use,
- broken,
- repaired,
- available
- }
- function changeStatus(Condition s) public returns (string) {
- if (bikeCondition == Condition.broken && (s == Condition.in_use || s == Condition.available)) {
- bikeBattery.chargeLevel -= 20;
- return "bike must be repaired first";
- } else {
- bikeCondition = s;
- bikeBattery.chargeLevel -= 20;
- return "color changed";
- }
- }
- constructor() public {
- bikeCondition = Condition.available;
- bikeBattery.chargeLevel = 100;
- riders.push(msg.sender);
- bikeOwner = msg.sender;
- }
- }
Add Comment
Please, Sign In to add comment