Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. pragma experimental ABIEncoderV2;
  2.  
  3. contract MailService{
  4. struct Table{
  5. string cities;
  6. string indexes;
  7. }
  8.  
  9. mapping(uint => Table) public table;
  10. mapping(string => string) public addressToIndex;
  11. mapping(string => string) public indexToAddress;
  12. uint tablesCount;
  13.  
  14. constructor () public {
  15. string[17] memory cities = ['Санкт-Петербург', 'Всеволожск (Главное отделение)', 'Всеволожск (Почтамт №1)', 'Всеволожск (Почтамт №2)', 'Всеволожск (Почтамт №3)', 'Луга (Главное отделение)', 'Луга (Почтамт №1)', 'Луга (Почтамт №2)', 'Луга (Почтамт №3)', 'Гатчино (Главное отделение)', 'Гатчино (Почтамт №1)', 'Гатчино (Почтамт №2)', 'Гатчино (Почтамт №3)', 'Тосно (Главное отделение)', 'Тосно (Почтамт №1)', 'Тосно (Почтамт №2)', 'Тосно (Почтамт №3)'];
  16. string[17] memory indexes = ['187100', '188640', '188641', '188642', '188643', '188230', '188231', '188232', '188233', '188230', '188231', '188232', '188233', '187000', '187001', '187002', '187003'];
  17. for(uint i = 0; i < cities.length; i++){
  18. Table storage tableL = table[i];
  19. tablesCount++;
  20. tableL.cities = cities[i];
  21. tableL.indexes = indexes[i];
  22. addressToIndex[cities[i]] = indexes[i];
  23. indexToAddress[indexes[i]] = cities[i];
  24. }
  25. }
  26.  
  27. function getTable() public view returns (Table[] memory){
  28. Table[] memory tables = new Table[](tablesCount);
  29. for(uint i = 0; i < tablesCount; i++){
  30. Table storage tablesL = table[i];
  31. tables[i] = tablesL;
  32. }
  33. return tables;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement