Skip to content

Instantly share code, notes, and snippets.

@alexroan
Last active June 16, 2021 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexroan/d2c6ef51d47e567eff05cbe8a203266b to your computer and use it in GitHub Desktop.
Save alexroan/d2c6ef51d47e567eff05cbe8a203266b to your computer and use it in GitHub Desktop.
Simple Car Registry
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