Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/Base/inheirtence.sol": {
"content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity 0.8.20;\r
\r
/**\r
* @title Employee\r
* @dev Abstract contract defining common properties and behavior for employees.\r
*/\r
abstract contract Employee {\r
uint public idNumber; // Unique identifier for the employee\r
uint public managerId; // Identifier of the manager overseeing the employee\r
\r
/**\r
* @dev Constructor to initialize idNumber and managerId.\r
* @param _idNumber The unique identifier for the employee.\r
* @param _managerId The identifier of the manager overseeing the employee.\r
*/\r
constructor(uint _idNumber, uint _managerId) {\r
idNumber = _idNumber;\r
managerId = _managerId;\r
}\r
\r
/**\r
* @dev Abstract function to be implemented by derived contracts to get the annual cost of the employee.\r
* @return The annual cost of the employee.\r
*/\r
function getAnnualCost() public virtual returns (uint);\r
}\r
\r
/**\r
* @title Salaried\r
* @dev Contract representing employees who are paid an annual salary.\r
*/\r
contract Salaried is Employee {\r
uint public annualSalary; // The annual salary of the employee\r
\r
/**\r
* @dev Constructor to initialize the Salaried contract.\r
* @param _idNumber The unique identifier for the employee.\r
* @param _managerId The identifier of the manager overseeing the employee.\r
* @param _annualSalary The annual salary of the employee.\r
*/\r
constructor(uint _idNumber, uint _managerId, uint _annualSalary) Employee(_idNumber, _managerId) {\r
annualSalary = _annualSalary;\r
}\r
\r
/**\r
* @dev Overrides the getAnnualCost function to return the annual salary of the employee.\r
* @return The annual salary of the employee.\r
*/\r
function getAnnualCost() public override view returns (uint) {\r
return annualSalary;\r
}\r
}\r
\r
/**\r
* @title Hourly\r
* @dev Contract representing employees who are paid an hourly rate.\r
*/\r
contract Hourly is Employee {\r
uint public hourlyRate; // The hourly rate of the employee\r
\r
/**\r
* @dev Constructor to initialize the Hourly contract.\r
* @param _idNumber The unique identifier for the employee.\r
* @param _managerId The identifier of the manager overseeing the employee.\r
* @param _hourlyRate The hourly rate of the employee.\r
*/\r
constructor(uint _idNumber, uint _managerId, uint _hourlyRate) Employee(_idNumber, _managerId) {\r
hourlyRate = _hourlyRate;\r
}\r
\r
/**\r
* @dev Overrides the getAnnualCost function to calculate the annual cost based on the hourly rate.\r
* Assuming a full-time workload of 2080 hours per year.\r
* @return The annual cost of the employee.\r
*/\r
function getAnnualCost() public override view returns (uint) {\r
return hourlyRate * 2080;\r
}\r
}\r
\r
/**\r
* @title Manager\r
* @dev Contract managing a list of employee IDs.\r
*/\r
contract Manager {\r
uint[] public employeeIds; // List of employee IDs\r
\r
/**\r
* @dev Function to add a new employee ID to the list.\r
* @param _reportId The ID of the employee to be added.\r
*/\r
function addReport(uint _reportId) public {\r
employeeIds.push(_reportId);\r
}\r
\r
/**\r
* @dev Function to reset the list of employee IDs.\r
*/\r
function resetReports() public {\r
delete employeeIds;\r
}\r
}\r
\r
/**\r
* @title Salesperson\r
* @dev Contract representing salespeople who are paid hourly.\r
*/\r
contract Salesperson is Hourly {\r
/**\r
* @dev Constructor to initialize the Salesperson contract.\r
* @param _idNumber The unique identifier for the employee.\r
* @param _managerId The identifier of the manager overseeing the employee.\r
* @param _hourlyRate The hourly rate of the employee.\r
*/\r
constructor(uint _idNumber, uint _managerId, uint _hourlyRate) \r
Hourly(_idNumber, _managerId, _hourlyRate) {}\r
}\r
\r
/**\r
* @title EngineeringManager\r
* @dev Contract representing engineering managers who are paid an annual salary and have managerial responsibilities.\r
*/\r
contract EngineeringManager is Salaried, Manager {\r
/**\r
* @dev Constructor to initialize the EngineeringManager contract.\r
* @param _idNumber The unique identifier for the employee.\r
* @param _managerId The identifier of the manager overseeing the employee.\r
* @param _annualSalary The annual salary of the employee.\r
*/\r
constructor(uint _idNumber, uint _managerId, uint _annualSalary) \r
Salaried(_idNumber, _managerId, _annualSalary) {}\r
}\r
\r
/**\r
* @title InheritanceSubmission\r
* @dev Contract for deploying instances of Salesperson and EngineeringManager.\r
*/\r
contract InheritanceSubmission {\r
address public salesPerson; // Address of the deployed Salesperson instance\r
address public engineeringManager; // Address of the deployed EngineeringManager instance\r
\r
/**\r
* @dev Constructor to initialize the InheritanceSubmission contract.\r
* @param _salesPerson Address of the deployed Salesperson instance.\r
* @param _engineeringManager Address of the deployed EngineeringManager instance.\r
*/\r
constructor(address _salesPerson, address _engineeringManager) {\r
salesPerson = _salesPerson;\r
engineeringManager = _engineeringManager;\r
}\r
}"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-10-30 14:51:43
Comments
Log in to comment.
No comments yet.