-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74a8d0a
commit 19d3928
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.5.0 <0.9.0; | ||
|
||
contract Day5 { | ||
//Create a structure -> struct Book { string title; string author; uint256 book_id; } | ||
struct Book { | ||
string title; | ||
string author; | ||
uint256 book_id; | ||
} | ||
Book[5] book; | ||
uint256 i = 1; | ||
|
||
function setBook( | ||
//Create two functions a) setBook(title(string),author(string),id(uint)) - To set the book title, author and id given in the "Book type" array. | ||
string memory _titile, | ||
string memory _author, | ||
uint256 _id | ||
) public { | ||
book[i] = Book(_titile, _author, _id); | ||
i++; | ||
} | ||
//getBook(id(uint)) - To get the book title,author and id of the Book whoose id is passed as an argument. | ||
function getBook(uint256 _i) | ||
public | ||
view | ||
returns ( | ||
string memory, | ||
string memory, | ||
uint256 | ||
) | ||
{ | ||
return (book[_i].title, book[_i].author, book[_i].book_id); | ||
} | ||
} |