Last active
June 16, 2021 02:33
-
-
Save alexroan/d2c6ef51d47e567eff05cbe8a203266b to your computer and use it in GitHub Desktop.
Simple Car Registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.0; | |
contract Fabcar { | |
struct Car { | |
string make; | |
string model; | |
string color; | |
string owner; | |
} | |
Car[] public cars; | |
constructor() public { | |
cars.push(Car('Toyota', 'Prius', 'blue', 'Tomoko')); | |
cars.push(Car('Ford', 'Mustang', 'red', 'Brad')); | |
cars.push(Car('Hyundai', 'Tucson', 'green', 'Jin Soo')); | |
cars.push(Car('Volkswagen', 'Passat', 'yellow', 'Max')); | |
cars.push(Car('Tesla', 'S', 'black', 'Adriana')); | |
cars.push(Car('Peugeot', '205', 'purple', 'Michel')); | |
cars.push(Car('Chery', 'S22L', 'white', 'Aarav')); | |
cars.push(Car('Fiat', 'Punto', 'violet', 'Pari')); | |
cars.push(Car('Tata', 'Nano', 'indigo', 'Valeria')); | |
cars.push(Car('Holden', 'Barina', 'brown', 'Shotaro')); | |
} | |
function createCar(string memory _make, string memory _model, string memory _color, string memory _owner) public{ | |
cars.push(Car(_make, _model, _color, _owner)); | |
} | |
function changeCarOwner(uint _id, string memory _owner) public { | |
cars[_id].owner = _owner; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment