Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma experimental ABIEncoderV2;
- contract MailService{
- struct Table{
- string cities;
- string indexes;
- }
- mapping(uint => Table) public table;
- mapping(string => string) public addressToIndex;
- mapping(string => string) public indexToAddress;
- uint tablesCount;
- constructor () public {
- string[17] memory cities = ['Санкт-Петербург', 'Всеволожск (Главное отделение)', 'Всеволожск (Почтамт №1)', 'Всеволожск (Почтамт №2)', 'Всеволожск (Почтамт №3)', 'Луга (Главное отделение)', 'Луга (Почтамт №1)', 'Луга (Почтамт №2)', 'Луга (Почтамт №3)', 'Гатчино (Главное отделение)', 'Гатчино (Почтамт №1)', 'Гатчино (Почтамт №2)', 'Гатчино (Почтамт №3)', 'Тосно (Главное отделение)', 'Тосно (Почтамт №1)', 'Тосно (Почтамт №2)', 'Тосно (Почтамт №3)'];
- string[17] memory indexes = ['187100', '188640', '188641', '188642', '188643', '188230', '188231', '188232', '188233', '188230', '188231', '188232', '188233', '187000', '187001', '187002', '187003'];
- for(uint i = 0; i < cities.length; i++){
- Table storage tableL = table[i];
- tablesCount++;
- tableL.cities = cities[i];
- tableL.indexes = indexes[i];
- addressToIndex[cities[i]] = indexes[i];
- indexToAddress[indexes[i]] = cities[i];
- }
- }
- function getTable() public view returns (Table[] memory){
- Table[] memory tables = new Table[](tablesCount);
- for(uint i = 0; i < tablesCount; i++){
- Table storage tablesL = table[i];
- tables[i] = tablesL;
- }
- return tables;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement