feat: classroom problem

This commit is contained in:
Ting-Jun Wang 2024-03-21 22:40:51 +08:00
parent 017dae519f
commit 8e1fd3c4fe
Signed by: snsd0805
GPG Key ID: D175E969960C4B16

View File

@ -4,9 +4,16 @@ pragma solidity ^0.8.0;
/* Problem 1 Interface & Contract */ /* Problem 1 Interface & Contract */
contract StudentV1 { contract StudentV1 {
// Note: You can declare some state variable // Note: You can declare some state variable
bool reg = false;
function register() external returns (uint256) { function register() external returns (uint256) {
// TODO: please add your implementaiton here // TODO: please add your implementaiton here
if (reg) {
return 123;
} else {
reg = true;
return 1001;
}
} }
} }
@ -18,6 +25,11 @@ interface IClassroomV2 {
contract StudentV2 { contract StudentV2 {
function register() external view returns (uint256) { function register() external view returns (uint256) {
// TODO: please add your implementaiton here // TODO: please add your implementaiton here
if (IClassroomV2(msg.sender).isEnrolled()) {
return 123;
} else {
return 1001;
}
} }
} }
@ -25,5 +37,11 @@ contract StudentV2 {
contract StudentV3 { contract StudentV3 {
function register() external view returns (uint256) { function register() external view returns (uint256) {
// TODO: please add your implementaiton here // TODO: please add your implementaiton here
// return gasleft();
if (gasleft() > 7000) {
return 1001;
} else {
return 123;
}
} }
} }