Advertisement
Nik_Perepelov

apteka

Nov 3rd, 2019
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. pragma solidity >=0.5.0 <0.5.12;
  2. pragma experimental ABIEncoderV2;
  3. contract Drugs{
  4. uint24 private cost;
  5. uint24 private num_of_drugs;
  6. string private type_of_drug;
  7. uint8 private priority;
  8. string private name;
  9.  
  10. constructor (uint24 en_cost, uint24 en_num, string memory en_type, uint8 en_priority, string memory en_name) public{
  11. cost = en_cost;
  12. num_of_drugs = en_num;
  13. type_of_drug = en_type;
  14. priority = en_priority;
  15. name = en_name;
  16. }
  17. function getCost() public view returns(uint24){
  18. return cost;
  19. }
  20. function getName() public view returns(string memory){
  21. return name;
  22. }
  23. }
  24.  
  25. contract Apteka{
  26. address[] private listOfDrugs;
  27. constructor() public{
  28. listOfDrugs.push(address(new Drugs(420, 100, "MindBoost", 50, "Fenotropil")));
  29. listOfDrugs.push(address(new Drugs(56, 30000, "Зыгср0", 100, "Glycin")));
  30. listOfDrugs.push(address(new Drugs(218, 300, "PainKiller", 255, "Nurofen")));
  31. }
  32. function getProducts() public view returns(address[] memory){
  33. return listOfDrugs;
  34. }
  35. function decodeAdd(address _prod) public view returns(string memory, uint24){
  36. Drugs tmp = Drugs(_prod);
  37. return (tmp.getName(), tmp.getCost());
  38. }
  39. function getAllInfo() public view returns(string[] memory, uint24[] memory){
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement