-
Notifications
You must be signed in to change notification settings - Fork 0
/
Automobile.sol
39 lines (31 loc) · 924 Bytes
/
Automobile.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.18;
contract Automotive{
//Variables
address public owner;
mapping(address=>bool) public buyers;
string public vehicleMake;
string public vehiclemodel;
uint public price;
// Event
event Purchase(address buyers,string make,string model,uint price);
//constructor
constructor() {
owner=msg.sender;
}
function buyvehicle(string memory _make,string memory _model) public payable{
require(msg.value>=price);
require(buyers[msg.sender]==false);
vehicleMake=_make;
vehiclemodel=_model;
buyers[msg.sender]=true;
emit Purchase(msg.sender,_make,_model,price);
}
function setprice(uint _prise) public{
require(msg.sender==owner);
price=_prise;
}
function checkownership()public view returns(bool){
return buyers[msg.sender];
}
}