mirror of https://github.com/hyperledger/besu
An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
813 B
38 lines
813 B
6 years ago
|
pragma solidity ^0.4.17;
|
||
|
|
||
|
contract Adoption {
|
||
|
address[16] public adopters;
|
||
|
// Adopting a pet
|
||
|
function adopt(uint petId) public returns (uint) {
|
||
|
require(petId >= 0 && petId <= 15);
|
||
|
|
||
|
adopters[petId] = msg.sender;
|
||
|
|
||
|
return petId;
|
||
|
}
|
||
|
// who has adopted this pet?
|
||
|
function getOwner(uint petId) public view returns (address) {
|
||
|
require(petId >= 0 && petId <= 15);
|
||
|
return adopters[petId];
|
||
|
}
|
||
|
|
||
|
// is this pet adopted?
|
||
|
function isAdopted(uint petId) public view returns (bool) {
|
||
|
require(petId >= 0 && petId <= 15);
|
||
|
return adopters[petId] != 0;
|
||
|
}
|
||
|
// Adopting a pet
|
||
|
function unadopt(uint petId) public returns (uint) {
|
||
|
require(petId >= 0 && petId <= 15);
|
||
|
|
||
|
adopters[petId] = 0;
|
||
|
|
||
|
return petId;
|
||
|
}
|
||
|
|
||
|
// Retrieving the adopters
|
||
|
function getAdopters() public view returns (address[16]) {
|
||
|
return adopters;
|
||
|
}
|
||
|
}
|