diff --git a/PokemonFactory.sol b/PokemonFactory.sol index a3267da1..35ffda8a 100644 --- a/PokemonFactory.sol +++ b/PokemonFactory.sol @@ -4,20 +4,26 @@ pragma solidity >=0.7.0 <0.9.0; contract PokemonFactory { - struct Pokemon { - uint id; - string name; - } + 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]++; + event eventNewPokemon( + uint id, + string name + ); + + function createPokemon (string memory _name, uint _id) public { + pokemons.push(Pokemon(_id, _name)); + pokemonToOwner[_id] = msg.sender; + ownerPokemonCount[msg.sender]++; + emit eventNewPokemon(_id, _name); } function getAllPokemons() public view returns (Pokemon[] memory) { @@ -26,10 +32,10 @@ contract PokemonFactory { function getResult() public pure returns(uint product, uint sum){ - uint a = 1; + uint a = 1; uint b = 2; product = a * b; - sum = a + b; + sum = a + b; } }