diff --git a/BT-1.sol b/BT-1.sol new file mode 100644 index 0000000..0593c9e --- /dev/null +++ b/BT-1.sol @@ -0,0 +1,27 @@ +//SPDX-License-Identifier:UNLICENSED +pragma solidity ^0.8.0; + +contract Bank_1{ + + uint16 balance = 0; + address public account; + + constructor(){ + account = msg.sender; + } + + + function checkBalance() public view returns (uint16){ + return balance; + } + + function deposit(uint16 amt) public payable { + require(amt > 0,"you cant deposit 0"); + balance += amt; + } + + function withdraw(uint16 amt) public payable { + require(balance >= amt,"balace is not enough"); + balance -= amt; + } +} \ No newline at end of file diff --git a/BT-2.sol b/BT-2.sol new file mode 100644 index 0000000..89ecafd --- /dev/null +++ b/BT-2.sol @@ -0,0 +1,36 @@ +//SPDX-License-Identifier:UNLICENSED +pragma solidity ^0.8.0; + +contract Student_1{ + + struct Student{ + uint16 id; + string name; + } + + Student[] public studentData; + + function addStudent(string memory name,uint16 id) public{ + for(uint8 i=0;i 0,"studentdata is empty"); + return studentData; + } + + function getLength() public view returns (uint256){ + return studentData.length; + } + + function getIndex(uint16 idx) public view returns (Student memory){ + require(idx < studentData.length,"index out of bound"); + return studentData[idx]; + } + +} \ No newline at end of file