-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hanan Wahabi - Pet Park Assignment #43
base: main
Are you sure you want to change the base?
Conversation
contracts/PetPark.sol
Outdated
} | ||
struct Borrower { | ||
Gender gender; | ||
uint256 age; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use a smaller uint for age here like uint8
_; | ||
} | ||
|
||
function add(AnimalType _animalType, uint256 _animalcount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be an external function (check other functions also)
} | ||
|
||
function giveBackAnimal() public { | ||
require( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since borrowers[msg.sender]
is being used multiple times, better to store it in a variable
contracts/PetPark.sol
Outdated
require(animalCounts[_animalType] > 0, "Selected animal not available"); | ||
|
||
if (borrowers[msg.sender].age > 0) { | ||
require(borrowers[msg.sender].age == _age, "Invalid Age"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since borrowers[msg.sender] is being repeated, you can store it in a memory variable
contracts/PetPark.sol
Outdated
"No borrowed pets" | ||
); | ||
animalCounts[borrowers[msg.sender].animalType] += 1; | ||
emit Returned(borrowers[msg.sender].animalType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this function also set the animal in borrower struct to NONE
No description provided.