From 8e1fd3c4fef887545cbcceecfa0fbdda93720738 Mon Sep 17 00:00:00 2001 From: Ting-Jun Wang Date: Thu, 21 Mar 2024 22:40:51 +0800 Subject: [PATCH] feat: classroom problem --- hw1/src/Classroom/Classroom.sol | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw1/src/Classroom/Classroom.sol b/hw1/src/Classroom/Classroom.sol index e37b973..079e73c 100644 --- a/hw1/src/Classroom/Classroom.sol +++ b/hw1/src/Classroom/Classroom.sol @@ -4,9 +4,16 @@ pragma solidity ^0.8.0; /* Problem 1 Interface & Contract */ contract StudentV1 { // Note: You can declare some state variable + bool reg = false; function register() external returns (uint256) { // TODO: please add your implementaiton here + if (reg) { + return 123; + } else { + reg = true; + return 1001; + } } } @@ -18,6 +25,11 @@ interface IClassroomV2 { contract StudentV2 { function register() external view returns (uint256) { // TODO: please add your implementaiton here + if (IClassroomV2(msg.sender).isEnrolled()) { + return 123; + } else { + return 1001; + } } } @@ -25,5 +37,11 @@ contract StudentV2 { contract StudentV3 { function register() external view returns (uint256) { // TODO: please add your implementaiton here + // return gasleft(); + if (gasleft() > 7000) { + return 1001; + } else { + return 123; + } } }