pragma solidity ^0.4.18; // Creating a contract contract Test { // Declaring a structure struct Book { string name; string writer; uint id; bool available; } // Declaring a structure object Book public book1; Book public book2; // Constructor to initialize book2 function Test() public { book2 = Book("Building Ethereum DApps", "Roberto Infante", 2, false); } // Function to set values for book1 function set_book_detail() public { book1 = Book("Introducing Ethereum and Solidity", "Chris Dannen", 1, true); } // Function to get book2 details function book_info() public view returns (string memory, string memory, uint, bool) { return (book2.name, book2.writer, book2.id, book2.available); } // Function to get book1 details function get_details() public view returns (string memory, uint) { return (book1.name, book1.id); } }
0.4.18