Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hanenWahabi
Copy link

No description provided.

}
struct Borrower {
Gender gender;
uint256 age;
Copy link
Contributor

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)
Copy link
Contributor

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(
Copy link
Contributor

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

require(animalCounts[_animalType] > 0, "Selected animal not available");

if (borrowers[msg.sender].age > 0) {
require(borrowers[msg.sender].age == _age, "Invalid Age");
Copy link
Contributor

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

"No borrowed pets"
);
animalCounts[borrowers[msg.sender].animalType] += 1;
emit Returned(borrowers[msg.sender].animalType);
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants