//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; contract SimpleStore { struct NewsFeed { uint id; string title; bool readable; } // 1. Создать структуру данных под сущность из реального мира mapping (uint => NewsFeed) listOfData; uint listOfDataLength; // Связать функции добавления/удаления/чтения с этой структурой function set(uint _id, string _value) public { listOfDataLength++; listOfData[_id] = NewsFeed(_id, _value, false); } function setPublic(uint _id) public { listOfData[_id].readable = true; } function get(uint _id) public constant returns (string) { return listOfData[_id].title; } function getReadable(uint _id) public constant returns (bool) { return listOfData[_id].readable; } function remove(uint _id) public { delete listOfData[_id]; } // Создать функцию логической операции на атрибутах структуры function showReadable(uint _id) public constant returns (string) { if (listOfData[_id].readable == true) { return "Я читаемый1!!!!!!"; } else { return "Ты не можешь читать меня"; } } // Создать функцию чтения структур по логическим условиям/циклам function howManyReadable() public constant returns (uint) { uint count = 0; for (uint iin = 0; iin < listOfDataLength; iin++) { if (listOfData[iin].readable == true) { count++; } } return count; } }
0.4.18