Contracts
Employee
Create anabstract contract called Employee. It should have:
- A public variable storing
idNumber - A public variable storing
managerId - A constructor that accepts arguments for and sets both of these variables
- A
virtualfunction calledgetAnnualCostthat returns auint
Salaried
A contract calledSalaried. It should:
- Inherit from
Employee - Have a public variable for
annualSalary - Implement an
overridefunction forgetAnnualCostthat returnsannualSalary - An appropriate constructor that performs any setup, including setting
annualSalary
Hourly
Implement a contract calledHourly. It should:
- Inherit from
Employee - Have a public variable storing
hourlyRate - Include any other necessary setup and implementation
The annual cost of an hourly employee is their hourly rate * 2080 hours.
Manager
Implement a contract calledManager. It should:
- Have a public array storing employee Ids
- Include a function called
addReportthat can add id numbers to that array - Include a function called
resetReportsthat can reset that array to empty
Salesperson
Implement a contract calledSalesperson that inherits from Hourly.
Engineering Manager
Implement a contract calledEngineeringManager that inherits from Salaried and Manager.
Deployments
You’ll have to do a more complicated set of deployments for this exercise. Deploy yourSalesperson and EngineeringManager contracts. You don’t need to separately deploy the other contracts.
Use the following values:
Salesperson
- Hourly rate is 20 dollars an hour
- Id number is 55555
- Manager Id number is 12345
Manager
- Annual salary is 200,000
- Id number is 54321
- Manager Id is 11111
Inheritance Submission
Copy the below contract and deploy it using the addresses of yourSalesperson and EngineeringManager contracts.
Submit your Contracts and Earn an NFT Badge! (BETA)
Hey, where’d my NFT go!?
Testnets are not permanent! Base Goerli will soon be sunset, in favor of Base Sepolia.As these are separate networks with separate data, your NFTs will not transfer over.Don’t worry! We’ve captured the addresses of all NFT owners on Base Goerli and will include them when we release the mechanism to transfer these NFTs to mainnet later this year! You can also redeploy on Sepolia and resubmit if you’d like!Submit your address for your copy of the
InheritanceSubmission contract that contains your other contract addresses.