Exercise - Demonstrate your knowledge of storage.
EmployeeStorage
. It should not inherit from any other contracts. It should have the following functions:
shares
storing the employee’s number of shares owned
name
which stores the employee’s namesalary
storing the employee’s salary
idNumber
storing the employee’s ID number
constructor
to set:
shares
name
salary
idNumber
shares
- 1000name
- Patsalary
- 50000idNumber
- 112358132134private
variables prevent other contracts from reading the value. You should use them as a part of clean programming practices, but marking a variable as private does not hide the value. All data is trivially available to anyone who knows how to fetch data from the chain.*You can make clever use of encryption though!viewSalary
that returns the value in salary
.
Write a function called viewShares
that returns the value in shares
.
grantShares
that increases the number of shares allocated to an employee by _newShares
. It should:
shares
TooManyShares
that returns the number of shares the employee would have with the new amount added_newShares
is greater than 5000, revert with a string message, “Too many shares”