forked from gelopfalcon/solidity-eth-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemonFactory.sol
More file actions
35 lines (25 loc) · 750 Bytes
/
PokemonFactory.sol
File metadata and controls
35 lines (25 loc) · 750 Bytes
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
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract PokemonFactory {
struct Pokemon {
uint id;
string name;
}
Pokemon[] private pokemons;
mapping (uint => address) public pokemonToOwner;
mapping (address => uint) ownerPokemonCount;
function createPokemon (string memory _name, uint _id) public {
pokemons.push(Pokemon(_id, _name));
pokemonToOwner[_id] = msg.sender;
ownerPokemonCount[msg.sender]++;
}
function getAllPokemons() public view returns (Pokemon[] memory) {
return pokemons;
}
function getResult() public pure returns(uint product, uint sum){
uint a = 1;
uint b = 2;
product = a * b;
sum = a + b;
}
}