-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathAccessModifiers.sol
More file actions
29 lines (25 loc) · 814 Bytes
/
AccessModifiers.sol
File metadata and controls
29 lines (25 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.13;
// You may modify this contract
contract Parent {
uint256 private _value;
function setValue_Parent(uint256 value)internal virtual returns(uint256){
_value = value;
}
function getValue_P()internal view virtual returns(uint256){
return _value;
}
}
contract Child is Parent {
/*
This exercise assumes you understand how access modifiers works.
1. `_value` variable is private and can only be accessed by `Parent` contract. Make the variable accessible
to `Parent` and `Child` contract ONLY.
*/
function setValue(uint256 newValue) public {
setValue_Parent(newValue);
}
function getValue() public view returns (uint256) {
return getValue_P();
}
}